/* ================================================
   SOPAN - Root CSS Variables
   ================================================ */
:root {
    --primary:          #2563eb;
    --primary-dark:     #1e40af;
    --primary-light:    #3b82f6;
    --secondary:        #1e293b;
    --secondary-dark:   #0f172a;
    --secondary-light:  #334155;

    --success:          #10b981;
    --success-light:    #d1fae5;
    --danger:           #ef4444;
    --danger-light:     #fee2e2;
    --warning:          #f59e0b;
    --warning-light:    #fef3c7;
    --info:             #3b82f6;
    --info-light:       #dbeafe;

    --light:            #f8fafc;
    --light-gray:       #f1f5f9;
    --gray:             #64748b;
    --dark:             #0f172a;
    --white:            #ffffff;
    --border:           #e2e8f0;

    --sidebar-bg:       #0f172a;
    --sidebar-width:    260px;
    --navbar-height:    64px;

    --card-radius:      14px;
    --border-radius:    10px;
    --border-radius-sm: 8px;

    --shadow:           0 1px 4px rgba(0,0,0,.07);
    --shadow-sm:        0 1px 2px rgba(0,0,0,.05);
    --shadow-lg:        0 4px 16px rgba(0,0,0,.10);
    --shadow-hover:     0 8px 24px rgba(0,0,0,.10);

    --font-primary:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-base:       14px;
    --font-size-sm:         13px;
    --font-size-lg:         16px;
    --font-weight-normal:   400;
    --font-weight-medium:   500;
    --font-weight-semibold: 600;
    --font-weight-bold:     700;

    --transition:       all 0.25s cubic-bezier(0.4,0,0.2,1);
    --transition-fast:  all 0.15s ease;
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-primary);
    font-size: var(--font-size-base);
    color: var(--secondary);
    background: var(--light);
    line-height: 1.6;
    overflow-x: hidden;
}

.site-loader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(248, 250, 252, 0.95);
    backdrop-filter: blur(10px);
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.site-loader--hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.site-loader__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 28px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 18px;
    box-shadow: 0 18px 60px rgba(15, 23, 42, 0.12);
    text-align: center;
}

.site-loader__spinner {
    width: 52px;
    height: 52px;
    border: 5px solid rgba(37, 99, 235, 0.18);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: site-loader-spin 0.85s linear infinite;
}

.site-loader__text {
    font-size: 14px;
    font-weight: 600;
    color: var(--secondary);
}

@keyframes site-loader-spin {
    to { transform: rotate(360deg); }
}

a { text-decoration: none; color: inherit; transition: var(--transition-fast); }
img { max-width: 100%; height: auto; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--light-gray); }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray); }

/* ── CANVAS ── */
canvas { max-width: 100%; }

/* ================================================
   LOGIN PAGE
   ================================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    position: relative;
    overflow: hidden;
    padding: 20px;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: rgba(255,255,255,.08);
    border-radius: 50%;
    top: -250px; right: -250px;
    animation: float 6s ease-in-out infinite;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: rgba(255,255,255,.06);
    border-radius: 50%;
    bottom: -200px; left: -200px;
    animation: float 8s ease-in-out infinite reverse;
}

@keyframes float {
    0%,100% { transform: translateY(0); }
    50%      { transform: translateY(20px); }
}

.login-container {
    background: var(--white);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
    animation: slideUp .4s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    padding: 36px 30px;
    text-align: center;
    color: var(--white);
}

.login-logo {
    font-size: 38px;
    font-weight: var(--font-weight-bold);
    letter-spacing: 2px;
    margin-bottom: 6px;
}

.login-subtitle {
    font-size: var(--font-size-sm);
    opacity: .9;
}

.login-body { padding: 36px 30px; }

.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: var(--font-weight-medium);
    color: var(--secondary);
    font-size: var(--font-size-sm);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--border-radius);
    font-size: var(--font-size-base);
    font-family: var(--font-primary);
    transition: var(--transition-fast);
    background: var(--white);
    color: var(--secondary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.password-wrapper { position: relative; }

.password-toggle {
    position: absolute;
    right: 14px; top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--gray);
    transition: var(--transition-fast);
}

.password-toggle:hover { color: var(--primary); }

.form-check { display: flex; align-items: center; margin-bottom: 18px; }
.form-check-input { width: 16px; height: 16px; margin-right: 8px; cursor: pointer; }
.form-check-label { font-size: var(--font-size-sm); color: var(--gray); cursor: pointer; }

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-primary);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    width: 100%;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-hover); }
.btn-primary:active { transform: translateY(0); }

.btn-success  { background: var(--success);  color: var(--white); }
.btn-danger   { background: var(--danger);   color: var(--white); }
.btn-warning  { background: var(--warning);  color: var(--white); }
.btn-secondary{ background: var(--secondary);color: var(--white); }
.btn-sm       { padding: 7px 14px; font-size: var(--font-size-sm); }

.btn-success:hover   { background: #059669; }
.btn-danger:hover    { background: #dc2626; }
.btn-warning:hover   { background: #d97706; }
.btn-secondary:hover { background: var(--secondary-dark); }

.forgot-password { text-align: center; margin-top: 18px; }
.forgot-password a { color: var(--primary); font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); }
.forgot-password a:hover { text-decoration: underline; }

/* ── ALERTS ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 18px;
    font-size: var(--font-size-sm);
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-danger  { background: var(--danger-light);  color: var(--danger);  border-left: 4px solid var(--danger); }
.alert-success { background: var(--success-light); color: var(--success); border-left: 4px solid var(--success); }
.alert-warning { background: var(--warning-light); color: var(--warning); border-left: 4px solid var(--warning); }
.alert-info    { background: var(--info-light);    color: var(--info);    border-left: 4px solid var(--info); }

/* ================================================
   BADGES
   ================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: var(--font-weight-semibold);
    text-transform: capitalize;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-info    { background: var(--info-light);    color: var(--info); }
.badge-primary { background: rgba(37,99,235,.1);   color: var(--primary); }

/* ================================================
   MODAL
   ================================================ */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(6px);
    overflow-y: auto;
    padding: 20px;
    animation: fadeIn .2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-dialog {
    background: var(--white);
    border-radius: 16px;
    max-width: 550px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideUp .3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    margin: auto;
    z-index: 10000;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

/* Forms inside modal dialogs must also be flex columns */
.modal-dialog > form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(40px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    flex-shrink: 0;
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.modal-title i {
    font-size: 18px;
    color: #2563eb;
}

.modal-close {
    background: #f1f5f9;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    color: #64748b;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.modal-close:hover {
    background: #fee2e2;
    color: #ef4444;
    transform: rotate(90deg);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.modal-body .form-group {
    margin-bottom: 14px;
}

.modal-body .form-group:last-child {
    margin-bottom: 0;
}

.modal-body .form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #1e293b;
    font-size: 13px;
}

.modal-body .form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    font-family: var(--font-primary);
    transition: all .2s;
    background: #ffffff;
    color: #1e293b;
}

.modal-body .form-control:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    background: #ffffff;
}

.modal-body .form-control:disabled {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
}

.modal-body select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.modal-body .row {
    display: flex;
    gap: 12px;
    margin: 0 -6px;
}

.modal-body .col-md-6 {
    flex: 1;
    padding: 0 6px;
    min-width: 0;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
    background: #f8fafc;
    flex-shrink: 0;
}

.modal-footer .btn {
    padding: 9px 18px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.modal-footer .btn-secondary {
    background: #ffffff;
    color: #64748b;
    border: 1.5px solid #e2e8f0;
}

.modal-footer .btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #475569;
}

.modal-footer .btn-primary {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.modal-footer .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.modal-footer .btn-primary:active {
    transform: translateY(0);
}

/* ── MODAL RESPONSIVE ── */
@media (max-width: 768px) {
    .modal {
        padding: 0;
        align-items: flex-start;
    }
    
    .modal-dialog {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
        min-height: 100vh;
    }
    
    .modal-header {
        padding: 14px 16px;
        position: sticky;
        top: 0;
        z-index: 10;
        background: #ffffff;
    }
    
    .modal-title {
        font-size: 16px;
    }
    
    .modal-body {
        padding: 16px;
        overflow-y: auto;
        flex: 1;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-body .row {
        flex-direction: column;
        gap: 0;
    }
    
    .modal-body .col-md-6 {
        padding: 0;
    }
    
    .modal-footer {
        padding: 12px 16px;
        flex-wrap: wrap;
        position: sticky;
        bottom: 0;
        z-index: 10;
        background: #f8fafc;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }
}

/* ================================================
   SPINNER
   ================================================ */
.spinner {
    border: 3px solid var(--light-gray);
    border-top-color: var(--primary);
    border-radius: 50%;
    width: 36px; height: 36px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================
   TOAST
   ================================================ */
.toast {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 14px 18px;
    margin-bottom: 10px;
    min-width: 280px;
    animation: toastIn .3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--font-size-sm);
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(60px); }
    to   { opacity: 1; transform: translateX(0); }
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info    { border-left: 4px solid var(--info); }

/* ================================================
   PWA INSTALL BANNER
   ================================================ */
.pwa-install-banner {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9998;
    width: min(440px, calc(100vw - 40px));
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid rgba(226, 232, 240, .96);
    border-radius: 14px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 18px 48px rgba(15, 23, 42, .18);
    transform: translateY(18px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
}

.pwa-install-banner.is-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.pwa-install-banner__icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;
    border-radius: 12px;
    background: rgba(37, 99, 235, .1);
    color: var(--primary);
    font-size: 18px;
}

.pwa-install-banner__content {
    min-width: 0;
    flex: 1;
}

.pwa-install-banner__content strong,
.pwa-install-banner__content span {
    display: block;
}

.pwa-install-banner__content strong {
    margin-bottom: 2px;
    color: var(--secondary);
    font-size: 14px;
    line-height: 1.25;
}

.pwa-install-banner__content span {
    color: var(--gray);
    font-size: 12px;
    line-height: 1.45;
}

.pwa-install-banner__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pwa-install-banner__btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 0;
    border-radius: 10px;
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: var(--transition-fast);
}

.pwa-install-banner__btn--primary {
    padding: 0 14px;
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 8px 18px rgba(37, 99, 235, .2);
}

.pwa-install-banner__btn--primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.pwa-install-banner__btn--icon {
    width: 38px;
    background: var(--light-gray);
    color: var(--gray);
}

.pwa-install-banner__btn--icon:hover {
    background: var(--danger-light);
    color: var(--danger);
}

@media (max-width: 575.98px) {
    .pwa-install-banner {
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
        align-items: flex-start;
    }

    .pwa-install-banner__actions {
        align-self: stretch;
    }

    .pwa-install-banner__btn--primary span {
        display: none;
    }
}

/* ================================================
   DATA TABLE (used in other pages)
   ================================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    font-size: var(--font-size-sm);
}
.data-table thead { background: var(--light); }
.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: var(--font-weight-semibold);
    color: var(--secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
    border-bottom: 2px solid var(--light-gray);
}
.data-table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--light-gray);
    color: var(--secondary);
    vertical-align: middle;
    white-space: nowrap;
}
.data-table tbody tr { transition: var(--transition-fast); }
.data-table tbody tr:hover { background: var(--light); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ================================================
   CONTENT CARD (legacy pages)
   ================================================ */
.content-card {
    background: var(--white);
    border-radius: var(--card-radius);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
}
.card-title {
    font-size: 15px;
    font-weight: var(--font-weight-semibold);
    color: var(--secondary);
    margin: 0;
}
.card-body { padding: 20px; background: var(--white); }

/* ================================================
   TABLE RESPONSIVE (legacy)
   ================================================ */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-responsive::-webkit-scrollbar { height: 4px; }

/* ================================================
   TASK ITEM
   ================================================ */
.task-item {
    background: var(--light);
    border-radius: var(--border-radius-sm);
    padding: 14px;
    margin-bottom: 10px;
    border: 1px solid var(--light-gray);
    transition: var(--transition-fast);
}
.task-item:hover { background: var(--white); box-shadow: var(--shadow-sm); }

/* ================================================
   UTILITIES
   ================================================ */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }
.text-muted   { color: var(--gray)    !important; }
.fw-semibold  { font-weight: var(--font-weight-semibold); }
.fw-bold      { font-weight: var(--font-weight-bold); }

/* ================================================
   RESPONSIVE — Login
   ================================================ */
@media (max-width: 480px) {
    .login-header { padding: 28px 20px; }
    .login-body   { padding: 28px 20px; }
    .login-logo   { font-size: 30px; }
}
