/**
 * assets/css/base.css
 * Core Design System, Global Layout, Shared Components & Header
 */

@import url('variables.css');

/* ==========================================================================
   BASE RESET & TYPOGRAPHY
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout container */
.container {
    max-width: 1250px;
    margin: 0 auto;
    padding: 2rem;
}

/* ==========================================================================
   GLOBAL HEADER & NAVIGATION
   ========================================================================== */
.main-header {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.85rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03), inset 0 -1px 0 rgba(0, 0, 0, 0.05);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    max-width: 1250px;
    margin: 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: var(--text-main);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1;
}

.brand:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

.brand-icon {
    background: linear-gradient(135deg, var(--primary) 0%, #60a5fa 100%);
    color: white;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 13px;
    font-size: 1.6rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.brand-name { 
    font-weight: 900; 
    font-size: 1.4rem; 
    letter-spacing: -0.04em; 
    background: linear-gradient(135deg, var(--text-main) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.brand-separator {
    color: var(--border-color);
}
.brand-subname {
    font-weight: 800;
    font-size: 0.9rem;
    letter-spacing: -0.025em;
    text-transform: uppercase;
    color: var(--primary);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-nav .btn-ghost {
    padding: 0 0.85rem;
    min-width: 44px;
    width: auto;
    height: 44px;
    font-size: 0.9rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    white-space: nowrap;
}

.header-nav .btn-ghost.active-nav {
    background: var(--primary) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
    transform: translateY(-3px);
    border-radius: 12px !important;
}

.user-pill {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 0 1.25rem;
    border-right: 1.5px solid var(--border-color);
    margin-right: 0.5rem;
    line-height: 1.3;
}

.user-name {
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--text-main);
}

.user-role {
    font-size: 0.65rem;
    font-weight: 900;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.8;
}

/* Dropdown Navigation Groups */
.nav-group {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.nav-group-toggle {
    display: none !important; /* Hidden on desktop */
}

.nav-group-menu {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.nav-text {
    display: none; /* Hidden on desktop */
}

/* ==========================================================================
   SHARED UI COMPONENTS
   ========================================================================== */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 0.875rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    text-decoration: none !important;
    font-family: inherit;
}

.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); transform: translateY(-1px); }

.btn-ghost { background: #f1f5f9; color: var(--text-main); border-color: var(--border-color); }
.btn-ghost:hover { background: #e2e8f0; }

.btn-success { background-color: var(--success); color: white; border: none; }
.btn-success:hover { background-color: var(--success-hover); transform: translateY(-1px); }

.btn-warning { background-color: var(--warning); color: white; }
.btn-warning:hover { background-color: var(--warning-hover); }

.btn-danger { background-color: var(--danger); color: white; }
.btn-danger:hover { background-color: var(--danger-hover); }
.btn-logout { color: var(--danger) !important; }
.btn-sm {
    padding: 0.35rem 0.85rem !important;
    height: 28px !important;
    font-size: 0.75rem !important;
    border-radius: var(--radius-sm) !important;
}
.btn-icon-sq {
    height: 32px !important;
    width: 44px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.btn-save {
    background-color: var(--success);
    border-color: var(--success);
    color: white;
}
.btn-save:hover {
    background-color: var(--success-hover);
    border-color: var(--success-hover);
}
.btn-outline-danger {
    color: var(--danger) !important;
    border: 1px solid #fee2e2 !important;
    background: white !important;
}
.btn-outline-danger:hover {
    background: #fef2f2 !important;
    border-color: #fca5a5 !important;
}
.btn-outline-info {
    color: #2563eb !important;
    border: 1px solid #bfdbfe !important;
    background: #eff6ff !important;
}
.btn-outline-info:hover {
    background: #dbeafe !important;
    border-color: #93c5fd !important;
}

.empty-state-card {
    text-align: center;
    padding: 3.5rem 2rem;
    color: var(--text-muted);
    background: white;
    border-radius: var(--radius-xl);
    border: 1px dashed var(--border-color);
    font-size: 0.95rem;
    font-weight: 500;
}

/* ==========================================================================
   UNIVERSAL MODAL DIALOGS
   ========================================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1100;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.modal-box {
    background: white;
    padding: 2rem;
    border-radius: 28px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-sizing: border-box;
}
.modal-box-sm { max-width: 480px; }
.modal-box-md { max-width: 550px; }
.modal-box-lg { max-width: 720px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}
.modal-title {
    margin: 0;
    font-weight: 900;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    transition: color 0.15s;
    padding: 0;
}
.modal-close-btn:hover {
    color: var(--text-main);
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.icon-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    text-decoration: none;
    font-size: 1rem;
    padding: 0;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.icon-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.icon-btn-success {
    background: var(--success);
    border-color: var(--success);
    color: white;
}
.icon-btn-success:hover {
    background: var(--success-hover);
    border-color: var(--success-hover);
}

.icon-btn-danger {
    color: var(--danger);
    background: white;
    border-color: var(--border-color);
}
.icon-btn-danger:hover {
    background: #fef2f2;
    border-color: #fee2e2;
}

.icon-btn-ghost {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: var(--text-main);
}
.icon-btn-ghost:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

/* Navigation Switcher (Month / Period Switcher) */
.nav-switcher {
    display: inline-flex;
    align-items: center;
    background: white;
    padding: 0.35rem 0.5rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    width: fit-content;
    gap: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
}
.nav-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid transparent;
    background: #f1f5f9;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 900;
    font-size: 1.1rem;
    transition: all 0.15s ease;
    line-height: 1;
}
.nav-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: #bfdbfe;
    transform: translateY(-1px);
}
.nav-current {
    padding: 0 1rem;
    font-weight: 900;
    font-size: 1.05rem;
    min-width: 140px;
    text-align: center;
    color: var(--text-main);
    user-select: none;
}

/* Status Badges */
.status-badge {
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.status-submitted {
    background: #dcfce7;
    color: #166534;
}
.status-open {
    background: #fffbeb;
    color: #92400e;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 2rem;
    padding: 2.5rem;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8fafc;
}

/* Tables */
.table-responsive { overflow-x: auto; }
.ticket-table { width: 100%; border-collapse: collapse; }
.ticket-table th, .ticket-table td { padding: 1rem 1.5rem; text-align: left; border-bottom: 1px solid var(--border-color); }
.ticket-table th { background-color: #f8fafc; font-weight: 700; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* Forms & Controls */
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    background: #fff;
    transition: 0.2s;
    color: var(--text-main);
}
input[type="checkbox"], input[type="radio"] {
    width: 18px !important;
    height: 18px !important;
    padding: 0 !important;
    margin: 0 !important;
    accent-color: var(--primary);
    cursor: pointer;
    vertical-align: middle;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}
input[type="time"], input[type="number"] {
    padding: 0.4rem 0.6rem !important;
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.modal-box {
    background: white;
    border-radius: 16px;
    max-width: 620px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    padding: 1.75rem;
    box-shadow: var(--shadow-xl);
    animation: modalFadeIn 0.2s ease-out;
    box-sizing: border-box;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Loading Overlay */
.loader {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    font-weight: 800;
}
.loading-active {
    display: flex;
}

/* ==========================================================================
   RESPONSIVENESS (Header & Navigation)
   ========================================================================== */
@media (max-width: 768px) {
    .header-content { padding: 0 1rem; }
    .brand-name { font-size: 1.1rem; }
    .user-pill { padding: 0 0.5rem; border-right: none; margin-right: 0; }
    .user-role { display: none; }
    .header-nav { gap: 0.5rem; }
    .btn { padding: 0.5rem 0.8rem; font-size: 0.8rem; }
    .container { padding: 1rem; }
    .brand { gap: 0.5rem; }

    .nav-group-toggle {
        display: flex !important;
    }

    .nav-group-menu {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        margin-top: 0.5rem;
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 16px;
        box-shadow: var(--shadow-lg);
        padding: 0.5rem;
        z-index: 1000;
        flex-direction: column;
        min-width: 210px;
        gap: 0.25rem;
    }

    .nav-group.open .nav-group-menu {
        display: flex;
    }

    .nav-group-menu .btn {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: auto !important;
        justify-content: flex-start !important;
        text-align: left;
        padding: 0.6rem 1rem !important;
        font-size: 0.95rem !important;
        box-sizing: border-box;
        border-radius: 10px;
        display: flex !important;
        align-items: center;
        gap: 0.5rem;
        border: 1px solid transparent;
        background: transparent !important;
        color: var(--text-main) !important;
        box-shadow: none !important;
        transform: none !important;
    }
    
    .nav-group-menu .btn:hover {
        background: var(--primary-light) !important;
        color: var(--primary) !important;
    }

    .nav-group-menu .btn.active-nav {
        background: var(--primary-light) !important;
        color: var(--primary) !important;
        font-weight: 800;
    }
    
    .nav-group-menu .btn span.nav-text {
        display: inline !important;
        font-weight: 700;
    }
}

@media (max-width: 650px) {
    .brand-name { display: none; }
    .btn span { display: none; }
    .user-pill { display: none; }
}

@media (max-width: 400px) {
    .header-nav { gap: 0.35rem; }
    .brand-icon { width: 34px; height: 34px; font-size: 1.2rem; }
}

/* ==========================================================================
   ADMIN IMPERSONATION / USER INSPECTION BANNER
   ========================================================================== */
.admin-user-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 0.85rem 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    gap: 1rem;
    flex-wrap: wrap;
}

.admin-user-info {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.admin-user-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.admin-user-text {
    display: flex;
    flex-direction: column;
}

.admin-user-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: #1e40af;
}

.admin-user-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: #1e3a8a;
}

.admin-user-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .admin-user-banner {
        flex-direction: column;
        align-items: stretch;
    }
    .admin-user-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

/* ==========================================================================
   TOAST NOTIFICATIONS & CONFIRM DIALOGS
   ========================================================================== */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    pointer-events: none;
    max-width: 420px;
    width: calc(100vw - 3rem);
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.95rem 1.15rem;
    background: white;
    border-radius: 14px;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.08);
    border: 1px solid var(--border-color);
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--text-main);
    transform: translateX(110%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.hide {
    transform: translateX(110%);
    opacity: 0;
}

.toast-icon {
    font-size: 1.25rem;
    line-height: 1;
    flex-shrink: 0;
}

.toast-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toast-title {
    font-weight: 700;
    font-size: 0.85rem;
}

.toast-message {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.toast-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0;
    opacity: 0.6;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.toast-close:hover {
    opacity: 1;
}

/* Toast Variants */
.toast-error {
    border-left: 4px solid #ef4444;
    background: #fffafa;
}
.toast-error .toast-title { color: #b91c1c; }

.toast-success {
    border-left: 4px solid #10b981;
    background: #f0fdf4;
}
.toast-success .toast-title { color: #15803d; }

.toast-warning {
    border-left: 4px solid #f59e0b;
    background: #fffbeb;
}
.toast-warning .toast-title { color: #b45309; }

.toast-info {
    border-left: 4px solid #2563eb;
    background: #eff6ff;
}
.toast-info .toast-title { color: #1d4ed8; }

/* Global Custom Confirm Modal */
.app-confirm-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.45);
    align-items: center;
    justify-content: center;
    z-index: 1200;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.app-confirm-box {
    background: white;
    padding: 1.75rem 1.75rem 1.5rem 1.75rem;
    border-radius: 20px;
    width: 90%;
    max-width: 440px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.15), 0 10px 10px -5px rgba(0,0,0,0.04);
    animation: confirmModalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}
@keyframes confirmModalPop {
    0% { transform: scale(0.95); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.app-confirm-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.75rem;
}
.app-confirm-icon {
    font-size: 1.5rem;
    line-height: 1;
}
.app-confirm-title {
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text-main);
}
.app-confirm-message {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}
.app-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
}
.app-confirm-actions .btn {
    min-width: 90px;
    font-weight: 700;
}

