/* --------------------------------------------------------------------------
   Components & UI Elements Stylesheet
   Glassmorphism Cards, Dynamic Tables, Modals, Badges, Alert Drawer & Printable Paper
   -------------------------------------------------------------------------- */

/* Glassmorphism Cards */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: var(--transition-normal);
}

.glass-card:hover {
    border-color: var(--border-highlight);
}

.glass-card.full-width {
    width: 100%;
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.card-header h3 {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header.space-between {
    justify-content: space-between;
}

.card-body {
    padding: 18px;
}

/* Custom Table Design */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    text-align: left;
}

.custom-table th, 
.custom-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.custom-table th {
    background-color: rgba(15, 23, 42, 0.6);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

[data-theme="light"] .custom-table th {
    background-color: #f1f5f9;
    color: #475569;
}

.custom-table tbody tr {
    transition: var(--transition-fast);
}

.custom-table tbody tr:hover {
    background-color: rgba(56, 189, 248, 0.05);
}

.main-register-table th,
.main-register-table td {
    padding: 10px 8px;
    vertical-align: middle;
    word-break: keep-all;
    word-wrap: break-word;
    white-space: normal;
}



.material-tag {
    display: inline-block;
    background: rgba(56, 189, 248, 0.1);
    color: var(--primary);
    border: 1px solid rgba(56, 189, 248, 0.2);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    margin-top: 2px;
    margin-right: 4px;
}

/* Compact Sleek Action Bar & Search Filters */
.action-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    background: var(--bg-card);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.search-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.filter-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.filter-group label {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    margin: 0;
}

.filter-group .form-control {
    height: 32px;
    padding: 4px 10px;
    font-size: 12px;
}

.flex-grow {
    flex-grow: 1;
}

.action-buttons {
    display: flex;
    gap: 6px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
}

.badge-primary { background: rgba(56, 189, 248, 0.15); color: var(--primary); }
.badge-emerald { background: rgba(16, 185, 129, 0.15); color: var(--emerald); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--amber); }
.badge-danger { background: rgba(244, 63, 94, 0.15); color: var(--rose); }
.badge-info { background: rgba(168, 85, 247, 0.15); color: var(--purple); }

/* Modal Dialog */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#manager-modal { z-index: 1200 !important; }
#manual-modal { z-index: 1150 !important; }
#defect-modal { z-index: 1180 !important; }
#labor-rate-modal { z-index: 1190 !important; }
#theme-modal { z-index: 1250 !important; }
#admin-login-modal { z-index: 1400 !important; }
#admin-control-modal { z-index: 1350 !important; }

.modal-backdrop.active {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}


.modal-dialog {
    background-color: #0f172a;
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 860px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
}

[data-theme="light"] .modal-dialog {
    background-color: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: #0f172a;
    z-index: 10;
}

[data-theme="light"] .modal-header {
    background: #ffffff;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.btn-close-modal {
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

.form-section-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--primary);
    margin: 16px 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 1px dashed var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-section-title.space-between {
    justify-content: space-between;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}


/* Alert Drawer & Backdrop (z-index 10000, 100% offscreen when inactive) */
.alert-drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.alert-drawer-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.alert-drawer {
    position: fixed;
    top: 0;
    right: -600px;
    width: 480px;
    max-width: 90vw;
    height: 100vh;
    background: #0f172a;
    border-left: 1px solid var(--border-color);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.6);
    z-index: 9999;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

[data-theme="light"] .alert-drawer {
    background: #ffffff;
}

.alert-drawer.active {
    right: 0 !important;
}


.drawer-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-header h3 {
    font-size: 14px;
    font-weight: 700;
}

.btn-close-drawer {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

.alert-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.alert-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    gap: 12px;
}

.alert-item.warning { border-left: 4px solid var(--amber); }
.alert-item.critical { border-left: 4px solid var(--rose); }

.alert-item .alert-icon {
    font-size: 18px;
    padding-top: 2px;
}

.alert-item .alert-content h4 {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
}

.alert-item .alert-content p {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.alert-item .dday-tag {
    font-size: 11px;
    font-weight: 700;
}

/* Printable Overlay & Paper */
.printable-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(8px);
    z-index: 2500;
    display: none;
    overflow-y: auto;
    padding: 30px 15px;
    box-sizing: border-box;
}

.printable-overlay.active {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.printable-paper {
    background: #ffffff;
    color: #111827;
    width: 100%;
    max-width: 297mm; /* A4 가로 인쇄 대응 297mm 적용 */
    padding: 15mm 15mm;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    position: relative;
    box-sizing: border-box;
    border-radius: 4px;
    margin: 0 auto 60px auto;
}

.printable-actions {
    position: fixed;
    bottom: 20px;
    right: 30px;
    display: flex;
    gap: 12px;
    z-index: 2010;
}

/* Single A4 Page Fit Construction Logbook */
.a4-single-page-ledger {
    font-family: 'Noto Sans KR', sans-serif;
    color: #111827;
    background: #ffffff;
    padding: 0;
    max-width: 100%;
}

.ledger-section-title {
    font-size: 11.5px;
    font-weight: 800;
    color: #1e3a8a;
    border-left: 3px solid #1e3a8a;
    padding-left: 6px;
    margin: 8px 0 4px 0;
}

.a4-single-page-ledger .ledger-table {
    margin-bottom: 6px;
    font-size: 10.5px;
}

.a4-single-page-ledger .ledger-table th {
    background-color: #f1f5f9;
    color: #0f172a;
    padding: 4px 6px;
    font-size: 10.5px;
}

.a4-single-page-ledger .ledger-table td {
    padding: 4px 6px;
    font-size: 10.5px;
}

/* Official Government Construction Ledger Form Style */
.ledger-paper {
    font-family: 'Noto Sans KR', sans-serif;
    color: #111827;
}

.ledger-header {
    text-align: center;
    border-bottom: 2px solid #111827;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.ledger-header .dept-name {
    font-size: 12px;
    font-weight: 700;
    color: #4b5563;
    letter-spacing: 1px;
}

.ledger-header h2 {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 4px;
    margin: 4px 0;
    color: #111827;
}

.ledger-meta-bar {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
}

.ledger-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-bottom: 10px;
}

.ledger-table th, .ledger-table td {
    border: 1px solid #374151;
    padding: 5px 8px;
    vertical-align: middle;
}

.ledger-table th {
    background-color: #f3f4f6;
    font-weight: 700;
    text-align: center;
    color: #111827;
}

.ledger-footer-stamp {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #9ca3af;
    font-size: 12px;
    font-weight: 600;
}

.stamp-box {
    border: 1px dashed #6b7280;
    padding: 8px 16px;
    border-radius: 4px;
}

/* File Drop Zone */
.file-drop-zone {
    border: 2px dashed var(--border-highlight);
    border-radius: var(--radius-lg);
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    background: rgba(15, 23, 42, 0.4);
    transition: var(--transition-normal);
}

.file-drop-zone:hover {
    border-color: var(--primary);
    background: rgba(56, 189, 248, 0.05);
}

.file-drop-zone .icon-large {
    font-size: 38px;
    color: var(--primary);
    margin-bottom: 12px;
}

.file-hidden-input {
    display: none;
}

/* Photo Grid */
.photo-preview-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.photo-preview-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
    position: relative;
}

.photo-preview-card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
}

.photo-preview-card input {
    margin-top: 6px;
    font-size: 11px;
}

.photo-preview-card .btn-remove-photo {
    position: absolute;
    top: 14px;
    right: 14px;
    background: rgba(244, 63, 94, 0.8);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    cursor: pointer;
}

/* Parsed Result Box */
.parsed-result-box {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 16px;
}

.parsed-result-box h4 {
    font-size: 13px;
    color: var(--emerald);
    margin-bottom: 10px;
}

.parsed-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
}

.parsed-item-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px dashed rgba(255,255,255,0.1);
}

.reg-list-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 350px;
    overflow-y: auto;
}

.reg-item-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
}

/* Print CSS */
/* KEE Career Confirmation Sheet Explicit Cell Wrap & Padding */
#kee-career-sheet-body .kee-official-table {
    table-layout: fixed !important;
    width: 100% !important;
    border-collapse: collapse !important;
    margin-bottom: 15px !important;
}

#kee-career-sheet-body .kee-official-table th,
#kee-career-sheet-body .kee-official-table td {
    white-space: normal !important;
    word-break: break-all !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    vertical-align: middle !important;
    line-height: 1.4 !important;
    padding: 6px 8px !important;
    font-size: 10.5px !important;
}

#printable-kee-career-sheet .printable-paper {
    max-width: 900px !important;
    width: 100% !important;
    background: #ffffff !important;
    color: #0f172a !important;
}



