/* ============================================================
   ISTA-GOMA · Attestation Automation
   Main Application Stylesheet
   Font: Wix Madefor Text
   ============================================================ */

:root {
    --ista-blue: #0a3d62;
    --ista-light-blue: #3c6382;
    --ista-gold: #d4a017;
    --ista-red: #c0392b;
    --ista-green: #27ae60;
    --bg-main: #f0f2f5;
    --bg-card: #ffffff;
    --text-dark: #1a1a2e;
    --text-muted: #6c757d;
    --border-color: #e0e0e0;
    --sidebar-width: 250px;
    --topbar-height: 60px;
    --radius: 10px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
    --font-main: 'Wix Madefor Text', 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-main);
    background: var(--bg-main);
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== LAYOUT ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--ista-blue);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    height: 40px;
    width: auto;
    border-radius: 6px;
    background: #fff;
    padding: 3px;
}

.sidebar-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-item.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-left-color: var(--ista-gold);
}

.nav-item .material-icons {
    font-size: 22px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
    margin-top: 12px;
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.sidebar-user-role {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
}

.logout-link {
    padding: 8px 0;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
}

.logout-link:hover {
    color: #ff6b6b;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-dark);
    display: none;
    padding: 4px;
}

.menu-toggle .material-icons { font-size: 24px; }

.topbar-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
    letter-spacing: -0.3px;
}

.page-content {
    padding: 24px;
    flex: 1;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
}

/* ===== STAT CARDS ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card .stat-icon .material-icons { font-size: 24px; color: #fff; }

.stat-card.blue .stat-icon { background: var(--ista-blue); }
.stat-card.gold .stat-icon { background: var(--ista-gold); }
.stat-card.green .stat-icon { background: var(--ista-green); }
.stat-card.red .stat-icon { background: var(--ista-red); }

.stat-card .stat-info h3 {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.5px;
}

.stat-card .stat-info p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

/* ===== TABLES ===== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

table.data-table th,
table.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

table.data-table th {
    background: var(--bg-main);
    font-weight: 700;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table.data-table tbody tr:hover {
    background: rgba(10,61,98,0.04);
}

table.data-table .actions {
    display: flex;
    gap: 8px;
}

table.data-table .actions a {
    color: var(--ista-light-blue);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

table.data-table .actions a:hover { color: var(--ista-blue); }
table.data-table .actions .delete { color: var(--ista-red); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-main);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--ista-blue);
    color: #fff;
}
.btn-primary:hover { background: #08304e; }

.btn-gold {
    background: var(--ista-gold);
    color: #fff;
}
.btn-gold:hover { background: #b88a0f; }

.btn-danger {
    background: var(--ista-red);
    color: #fff;
}
.btn-danger:hover { background: #a93226; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-dark);
}
.btn-outline:hover { background: var(--bg-main); }

.btn .material-icons { font-size: 18px; }

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-sm .material-icons { font-size: 16px; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5a6268; }
.btn-edit { background: var(--ista-light-blue); color: #fff; }
.btn-edit:hover { background: #2c5282; }

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 13px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font-main);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--ista-blue);
    box-shadow: 0 0 0 3px rgba(10,61,98,0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

/* ===== ALERTS ===== */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: #d4edda; color: #155724; }
.alert-error { background: #f8d7da; color: #721c24; }
.alert-info { background: #d1ecf1; color: #0c5460; }

.alert .material-icons { font-size: 20px; }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-blue { background: #d1ecf1; color: #0c5460; }
.badge-gold { background: #fff3cd; color: #856404; }
.badge-green { background: #d4edda; color: #155724; }
.badge-red { background: #f8d7da; color: #721c24; }

/* ===== MODALS ===== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--ista-blue);
}
.modal-close {
    font-size: 28px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.modal-close:hover { color: var(--ista-red); }
.modal form { padding: 24px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

/* ===== ALERTS ===== */
.alert-error {
    background: #f8d7da;
    color: #721c24;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.alert-success {
    background: #d4edda;
    color: #155724;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

/* ===== SEARCH BAR ===== */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
}

.search-bar input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font-main);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--ista-blue);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .material-icons {
    font-size: 64px;
    color: var(--border-color);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    font-weight: 700;
}

/* ===== QR PREVIEW ===== */
.qr-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.qr-preview img { border: 1px solid var(--border-color); border-radius: 4px; }

/* ===== OVERLAY (mobile sidebar) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}
.sidebar-overlay.show {
    display: block;
}

/* ===== RESPONSIVE: TABLET ===== */
@media (max-width: 1024px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== RESPONSIVE: MOBILE ===== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 260px;
        --topbar-height: 56px;
    }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: 0 0 40px rgba(0,0,0,0.3);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .menu-toggle {
        display: flex;
        align-items: center;
    }

    .topbar {
        padding: 0 16px;
    }
    .topbar-title {
        font-size: 18px;
    }

    .page-content {
        padding: 16px;
    }

    .card {
        padding: 18px;
        border-radius: var(--radius);
        margin-bottom: 16px;
    }
    .card-header {
        margin-bottom: 16px;
    }
    .card-title {
        font-size: 16px;
    }

    .stat-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 16px;
    }
    .stat-card {
        padding: 16px;
        gap: 14px;
    }
    .stat-card .stat-icon {
        width: 42px; height: 42px;
        border-radius: 10px;
    }
    .stat-card .stat-icon .material-icons { font-size: 20px; }
    .stat-card .stat-info h3 {
        font-size: 24px;
    }
    .stat-card .stat-info p {
        font-size: 12px;
    }

    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 12px 14px;
        font-size: 15px;
    }

    .btn {
        padding: 12px 18px;
        font-size: 14px;
    }

    .search-bar {
        gap: 8px;
    }
    .search-bar input {
        padding: 12px 14px;
        font-size: 15px;
    }

    .alert {
        padding: 12px 16px;
        font-size: 13px;
    }

    .empty-state {
        padding: 40px 16px;
    }
    .empty-state .material-icons {
        font-size: 48px;
    }
    .empty-state h3 {
        font-size: 16px;
    }

    /* ===== RESPONSIVE TABLES → CARDS ===== */
    .table-wrapper {
        margin: 0;
        padding: 0;
        overflow: visible;
    }
    table.data-table {
        min-width: 0;
        display: block;
    }
    table.data-table thead {
        display: none;
    }
    table.data-table tbody {
        display: block;
    }
    table.data-table tr {
        display: block;
        padding: 14px 0;
        border-bottom: 1px solid var(--border-color);
    }
    table.data-table tr:last-child {
        border-bottom: none;
    }
    table.data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border-bottom: none;
        text-align: right;
        gap: 12px;
    }
    table.data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 12px;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.3px;
        text-align: left;
        flex-shrink: 0;
    }
    table.data-table td.actions {
        justify-content: flex-end;
        padding-top: 8px;
    }
    table.data-table td.actions::before {
        display: none;
    }
    table.data-table .actions {
        gap: 12px;
    }
    table.data-table .actions a {
        width: 36px; height: 36px;
        border-radius: 8px;
        background: var(--bg-main);
        justify-content: center;
    }
    table.data-table .actions a .material-icons {
        font-size: 20px;
    }

    .sidebar-header {
        padding: 14px 16px;
    }
    .sidebar-logo {
        height: 36px;
    }
    .sidebar-title {
        font-size: 15px;
    }
    .nav-item {
        padding: 14px 16px;
        font-size: 15px;
    }
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
}

.pagination-info {
    color: var(--text-muted);
    font-size: 13px;
}

.pagination .btn-sm {
    padding: 6px 10px;
}

.pagination .btn-sm .material-icons {
    font-size: 18px;
}

/* ===== BUTTON ICON ===== */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(0,0,0,0.05);
}

/* ===== TEXT UTILITIES ===== */
.text-muted {
    color: var(--text-muted);
}

/* ===== SEARCHABLE DROPDOWN ===== */
.searchable-dropdown {
    position: relative;
    width: 100%;
}

.searchable-dropdown .dropdown-selected {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.searchable-dropdown .dropdown-selected:hover {
    border-color: var(--ista-light-blue);
}

.searchable-dropdown.open .dropdown-selected {
    border-color: var(--ista-blue);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.searchable-dropdown .dropdown-text {
    color: var(--text-color);
    font-size: 14px;
}

.searchable-dropdown .dropdown-text.placeholder {
    color: var(--text-muted);
}

.searchable-dropdown .dropdown-arrow {
    color: var(--ista-blue);
    font-size: 12px;
    transition: transform 0.2s ease;
}

.searchable-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.searchable-dropdown .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--ista-blue);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 300px;
    overflow: hidden;
}

.searchable-dropdown.open .dropdown-menu {
    display: block;
}

.searchable-dropdown .dropdown-search-wrapper {
    position: relative;
    border-bottom: 1px solid var(--border-color);
}

.searchable-dropdown .dropdown-search-wrapper .material-icons {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    font-size: 20px;
}

.searchable-dropdown .dropdown-search {
    width: 100%;
    padding: 12px 14px 12px 40px;
    border: none;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}

.searchable-dropdown .dropdown-search:focus {
    background: #f8f9fa;
}

.searchable-dropdown .dropdown-options {
    max-height: 220px;
    overflow-y: auto;
}

.searchable-dropdown .dropdown-option {
    padding: 10px 14px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}

.searchable-dropdown .dropdown-option:hover {
    background: #f0f7ff;
    border-left-color: var(--ista-blue);
}

.searchable-dropdown .dropdown-option.selected {
    background: #e3f2fd;
    border-left-color: var(--ista-gold);
}

.searchable-dropdown .dropdown-option.hidden {
    display: none;
}

.searchable-dropdown .dropdown-no-results {
    padding: 14px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}



/* ===== RESPONSIVE: SMALL MOBILE ===== */
@media (max-width: 380px) {
    .page-content {
        padding: 12px;
    }
    .card {
        padding: 14px;
    }
    .stat-card {
        padding: 14px;
        gap: 12px;
    }
    .stat-card .stat-icon {
        width: 38px; height: 38px;
    }
    .stat-card .stat-info h3 {
        font-size: 22px;
    }
    .topbar-title {
        font-size: 16px;
    }
    .btn {
        padding: 11px 16px;
        font-size: 13px;
    }
    .pagination {
        flex-wrap: wrap;
        gap: 8px;
    }
}
