/* style.css — Apex Awards Admin Layout */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background: var(--body-bg);
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-size: .9rem;
    color: var(--text-primary);
    overflow-x: hidden;
    max-width: 100vw;
}

/* ════════════════════════════
   NAVBAR
════════════════════════════ */
.top-navbar {
    background: var(--navbar-bg);
    height: var(--navbar-height);
    z-index: 1050;
    box-shadow: 0 2px 12px rgba(212, 175, 55, .15);
    border-bottom: 1px solid rgba(212, 175, 55, .2);
}

.top-navbar .navbar-brand {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: .3px;
    color: var(--navbar-text) !important;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.top-navbar .navbar-brand .brand-icon {
    color: var(--primary);
    font-size: 1.4rem;
}

.sidebar-toggle {
    padding: 0;
    border: none;
    color: var(--navbar-text) !important;
    opacity: .85;
    transition: opacity var(--transition), transform var(--transition);
}

.sidebar-toggle:hover {
    opacity: 1;
    transform: scale(1.08);
}

.avatar-circle {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #E6B422, #D4AF37);
    border: 2px solid rgba(212, 175, 55, .3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    color: #1a1408;
    flex-shrink: 0;
}

.top-navbar .dropdown-toggle {
    color: var(--navbar-text) !important;
    text-decoration: none;
    transition: opacity var(--transition);
}

.top-navbar .dropdown-toggle:hover {
    opacity: .85;
}

.top-navbar .dropdown-menu {
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .15);
    min-width: 220px;
}

/* ════════════════════════════
   SIDEBAR
════════════════════════════ */
.sidebar {
    width: var(--sidebar-width);
    height: calc(100vh - var(--navbar-height));
    background: var(--sidebar-bg);
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    z-index: 1040;
    transition: transform var(--transition);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(212, 175, 55, .15);
    box-shadow: 4px 0 24px rgba(0, 0, 0, .2);
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    /* allows flex child to shrink & scroll */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, .2) transparent;
}

/* Brand area inside sidebar */
.sidebar-brand {
    padding: 0 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(212, 175, 55, .12);
    margin-bottom: .75rem;
}

.sidebar-brand-inner {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    background: rgba(212, 175, 55, .08);
    border: 1px solid rgba(212, 175, 55, .2);
    border-radius: 12px;
}

.sidebar-brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #E6B422, #D4AF37);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #1a1408;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(212, 175, 55, .35);
}

.sidebar-brand-text {
    font-size: .85rem;
    font-weight: 700;
    color: #F9D976;
    line-height: 1.2;
}

.sidebar-brand-sub {
    font-size: .68rem;
    color: rgba(212, 175, 55, .5);
    font-weight: 500;
}

.sidebar-label {
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(212, 175, 55, .35);
    padding: .75rem 1.5rem .6rem;
}

.sidebar .nav {
    padding: 0 .75rem;
    gap: .2rem;
    display: flex;
    flex-direction: column;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: .8rem 1rem;
    border-radius: 12px;
    transition: all .25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: .85rem;
    font-size: .875rem;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.sidebar .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: linear-gradient(180deg, #F9D976, #D4AF37);
    border-radius: 0 3px 3px 0;
    transition: height .25s ease;
}

.sidebar .nav-link i {
    font-size: 1.1rem;
    flex-shrink: 0;
    opacity: .9;
    transition: all .25s;
    width: 20px;
    text-align: center;
}

.sidebar .nav-link:hover {
    background: rgba(212, 175, 55, .1);
    color: #F9D976;
    transform: translateX(4px);
}

.sidebar .nav-link:hover i {
    opacity: 1;
    transform: scale(1.15);
    color: #D4AF37;
}

.sidebar .nav-link:hover::before {
    height: 40%;
}

.sidebar .nav-link.active {
    background: linear-gradient(135deg, rgba(212, 175, 55, .18), rgba(212, 175, 55, .08));
    color: #F9D976;
    font-weight: 700;
    border: 1px solid rgba(212, 175, 55, .25);
    box-shadow: 0 4px 16px rgba(212, 175, 55, .15), inset 0 1px 0 rgba(255, 255, 255, .05);
}

.sidebar .nav-link.active::before {
    height: 55%;
}

.sidebar .nav-link.active i {
    opacity: 1;
    color: #D4AF37;
    filter: drop-shadow(0 0 6px rgba(212, 175, 55, .5));
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem .75rem .75rem;
    position: relative;
}

.sidebar-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 1.25rem;
    right: 1.25rem;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, .2), transparent);
}

.sidebar-footer .nav-link {
    color: #f87171 !important;
    border: 1px solid rgba(239, 68, 68, .15);
}

.sidebar-footer .nav-link:hover {
    background: rgba(239, 68, 68, .1) !important;
    color: #fca5a5 !important;
    border-color: rgba(239, 68, 68, .3);
    transform: translateX(0) !important;
}

.sidebar-footer .nav-link:hover i {
    color: #fca5a5 !important;
    transform: none !important;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

/* ════════════════════════════
   MAIN CONTENT
════════════════════════════ */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--navbar-height);
    padding: 2rem;
    min-height: calc(100vh - var(--navbar-height));
    transition: margin-left var(--transition);
    overflow-x: hidden;
    max-width: 100%;
}

.main-content.expanded {
    margin-left: 0;
}

/* ════════════════════════════
   CARDS
════════════════════════════ */
.card {
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    background: var(--card-bg);
    transition: box-shadow var(--transition), transform var(--transition);
}

.card-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
}

.card-footer {
    background: var(--card-bg);
    border-top: 1px solid var(--card-border);
}

/* Stat cards */
.stat-card {
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    transition: transform var(--transition), box-shadow var(--transition);
    cursor: default;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

/* ════════════════════════════
   TABLES — Responsive & Clean
════════════════════════════ */

/* Wrapper: horizontal scroll on small screens */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    min-width: 520px;
    /* prevents collapse on tiny screens */
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    font-weight: 700;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-secondary);
    background: #fefaf0;
    padding: .85rem 1.25rem;
    border-bottom: 2px solid #f0e0b0;
    white-space: nowrap;
    vertical-align: middle;
}

.table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color .2s;
}

.table th.sortable:hover {
    color: #D4AF37;
}

.table td {
    vertical-align: middle;
    padding: .85rem 1.25rem;
    color: var(--text-primary);
    border-bottom: 1px solid #f5f0e0;
    font-size: .875rem;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: background .15s;
}

.table tbody tr:hover {
    background: #fffdf5;
}

/* ID column — muted, smaller */
.table td.col-id {
    color: #a89870;
    font-weight: 600;
    font-size: .8rem;
    width: 52px;
}

/* Name cell — no wrap, bold */
.table td.col-name {
    font-weight: 700;
    color: #1a1408;
    white-space: nowrap;
}

/* Description — truncate long text */
.table td.col-desc {
    max-width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #7a6a4a;
    font-size: .82rem;
}

/* Actions column — always right-aligned, no wrap */
.table td.col-actions {
    white-space: nowrap;
    text-align: right;
    width: 90px;
}

/* Action button group */
.tbl-actions {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.tbl-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .82rem;
    cursor: pointer;
    background: transparent;
    transition: all .2s;
    flex-shrink: 0;
}

.tbl-btn.edit {
    border-color: rgba(212, 175, 55, .35);
    color: #B8960C;
}

.tbl-btn.edit:hover {
    background: rgba(212, 175, 55, .12);
    border-color: #D4AF37;
    color: #D4AF37;
}

.tbl-btn.delete {
    border-color: rgba(220, 38, 38, .25);
    color: #dc2626;
}

.tbl-btn.delete:hover {
    background: rgba(220, 38, 38, .08);
    border-color: #dc2626;
}

.tbl-btn.view {
    border-color: rgba(37, 99, 235, .25);
    color: #2563eb;
}

.tbl-btn.view:hover {
    background: rgba(37, 99, 235, .08);
    border-color: #2563eb;
}

/* ══════════════════════════════════════════
   MOBILE — Table → Card conversion
   Works on any .table inside .table-responsive
   Add data-label="Column Name" to each <td>
══════════════════════════════════════════ */
@media (max-width: 768px) {

    .table-responsive {
        overflow-x: hidden;
        width: 100%;
    }

    .table thead {
        display: none;
    }

    .table,
    .table tbody {
        display: block;
        width: 100%;
        min-width: unset;
    }

    /* Each row = a card */
    .table tbody tr {
        display: block;
        background: #fff;
        border: 1px solid #f0e0b0;
        border-radius: 14px;
        margin-bottom: .85rem;
        box-shadow: 0 2px 8px rgba(212, 175, 55, .07);
        transition: box-shadow .2s, border-color .2s;
        overflow: hidden;
        /* clip to rounded corners */
        width: 100%;
        box-sizing: border-box;
    }

    .table tbody tr:hover {
        border-color: rgba(212, 175, 55, .4);
        box-shadow: 0 4px 16px rgba(212, 175, 55, .12);
    }

    .table tbody tr.no-card {
        border: none;
        border-radius: 0;
        box-shadow: none;
        background: transparent;
        margin-bottom: 0;
        overflow: visible;
    }

    /* Each cell = label + value row */
    .table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .5rem;
        padding: .65rem 1rem;
        border-bottom: 1px solid #f5f0e0;
        font-size: .85rem;
        width: 100%;
        box-sizing: border-box;
        white-space: normal;
        overflow: hidden;
    }

    .table tbody td:last-child {
        border-bottom: none;
    }

    /* Label via ::before */
    .table tbody td::before {
        content: attr(data-label);
        font-size: .7rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .7px;
        color: #a89870;
        white-space: nowrap;
        flex-shrink: 0;
        min-width: 80px;
    }

    /* Hide ID cell */
    .table tbody td[data-label=""] {
        display: none;
    }

    /* Name — header of card, no label */
    .table tbody td.col-name {
        font-size: .95rem;
        font-weight: 700;
        padding: .85rem 1rem .7rem;
        border-bottom: 1px solid #f0e0b0;
        justify-content: flex-start;
    }

    .table tbody td.col-name::before {
        display: none;
    }

    /* Description */
    .table tbody td.col-desc>span {
        max-width: 65%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Actions — full-width bottom bar, NO overflow hidden */
    .table tbody td.col-actions {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: .5rem;
        padding: .7rem 1rem;
        background: #fefaf0;
        border-top: 1px solid #f0e0b0;
        border-bottom: none;
        overflow: visible;
        /* buttons must not clip */
        width: 100%;
        box-sizing: border-box;
    }

    .table tbody td.col-actions::before {
        display: none;
    }

    .table tbody td.col-actions .tbl-actions {
        display: flex;
        gap: .4rem;
        flex-shrink: 0;
    }

    .tbl-btn {
        width: 36px;
        height: 36px;
        font-size: .9rem;
    }

    .pos-input {
        width: 70px;
    }

    #catPagination,
    #pagination {
        justify-content: center;
    }
}

/* ════════════════════════════
   FILTER BAR
════════════════════════════ */
.filter-bar {
    background: #fff;
    border: 1px solid #f0e0b0;
    border-radius: 14px;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: nowrap;
    /* single row on desktop */
}

.filter-bar .input-group {
    flex: 1;
    min-width: 0;
}

.filter-bar .input-group-text {
    background: #fefaf0;
    border-color: #f0e0b0;
    border-radius: 9px 0 0 9px;
}

.filter-bar .form-control {
    border-color: #f0e0b0;
    font-size: .85rem;
    border-radius: 0 9px 9px 0;
}

.filter-bar .form-select {
    flex-shrink: 0;
    width: auto;
    min-width: 120px;
    max-width: 160px;
    border-color: #f0e0b0;
    font-size: .85rem;
    border-radius: 9px;
}

.filter-bar .form-control:focus,
.filter-bar .form-select:focus {
    border-color: #D4AF37;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, .12);
}

@media (max-width: 640px) {
    .filter-bar {
        flex-wrap: wrap;
    }

    .filter-bar .input-group {
        width: 100%;
        flex: unset;
    }

    .filter-bar .form-select {
        flex: 1;
        min-width: 0;
        max-width: 100%;
    }
}

/* ════════════════════════════
   BADGES
════════════════════════════ */
.badge {
    font-weight: 600;
    padding: .35em .75em;
    border-radius: 6px;
    font-size: .75rem;
}

.badge.text-bg-primary {
    background: linear-gradient(135deg, #E6B422, #D4AF37) !important;
    color: #1a1408 !important;
}

/* ════════════════════════════
   BUTTONS
════════════════════════════ */
.btn-primary {
    background: linear-gradient(135deg, #E6B422, #D4AF37);
    border: none;
    color: #1a1408;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(212, 175, 55, .35);
    transition: transform var(--transition), box-shadow var(--transition);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, #D4AF37, #B8960C);
    color: #1a1408;
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(212, 175, 55, .5);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #1a1408;
}

.btn {
    border-radius: var(--border-radius-sm);
    font-size: .875rem;
}

/* ════════════════════════════
   FORMS
════════════════════════════ */
.form-control,
.form-select {
    border-color: var(--card-border);
    border-radius: var(--border-radius-sm);
    font-size: .875rem;
    color: var(--text-primary);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .15);
}

.input-group-text {
    background: #fefaf0;
    border-color: var(--card-border);
    color: var(--text-secondary);
}

/* ════════════════════════════
   LOGIN PAGE
════════════════════════════ */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(160deg, #1a1408 0%, #2d1f0a 40%, #1a1408 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(212, 175, 55, .15) 0%, transparent 65%);
    top: -200px;
    right: -100px;
    pointer-events: none;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(212, 175, 55, .1) 0%, transparent 65%);
    bottom: 100px;
    left: -80px;
    pointer-events: none;
}

.login-card {
    width: 100%;
    max-width: 440px;
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .4);
    border: 1px solid rgba(212, 175, 55, .2);
    position: relative;
    z-index: 2;
}

.login-card .brand-icon {
    color: var(--primary);
    font-size: 2.8rem;
}

.login-card h4 {
    background: linear-gradient(135deg, #F9D976, #D4AF37);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ════════════════════════════
   SCROLLBAR
════════════════════════════ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, .3);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, .5);
}

/* ════════════════════════════
   RESPONSIVE
════════════════════════════ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, .3);
    }

    .main-content {
        margin-left: 0;
        padding: 1.25rem;
    }
}

/* ════════════════════════════
   APEX MODAL COMPONENTS
   (Alert & Confirm)
════════════════════════════ */
.apex-modal .modal-dialog {
    max-width: 360px;
}

.apex-modal-content {
    border: 1px solid rgba(212, 175, 55, .2);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .18);
}

.apex-modal-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 0 1rem;
    border-radius: 0;
}

.apex-modal-icon-wrap .bi {
    font-size: 2.8rem;
}

.apex-modal-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: #1a1408;
    margin-bottom: .5rem;
}

.apex-modal-msg {
    font-size: .875rem;
    color: #7a6a4a;
    margin-bottom: 0;
    line-height: 1.6;
}

.apex-modal-btn {
    color: #fff !important;
    font-weight: 600;
    border-radius: 10px;
    padding: .6rem 1rem;
    font-size: .875rem;
    transition: opacity .2s, transform .2s;
}

.apex-modal-btn:hover {
    opacity: .88;
    transform: translateY(-1px);
}

.apex-modal-btn-outline {
    background: #f5f0e0;
    border: 1px solid #e0d0a0;
    color: #7a6a4a !important;
    font-weight: 600;
    border-radius: 10px;
    padding: .6rem 1rem;
    font-size: .875rem;
    transition: background .2s;
}

.apex-modal-btn-outline:hover {
    background: #ede8d0;
}

/* ════════════════════════════
   RESPONSIVE — Navbar & Sidebar
════════════════════════════ */
@media (max-width: 768px) {

    /* Sidebar hidden by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        z-index: 1045;
        top: 0;
        height: 100vh;
        box-shadow: none;
    }

    /* Sidebar open state */
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 6px 0 32px rgba(0, 0, 0, .35);
    }

    /* Dark overlay behind sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .55);
        z-index: 1044;
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* Main content full width */
    .main-content {
        margin-left: 0 !important;
        padding: 1rem;
    }

    /* Navbar: tighter on mobile */
    .top-navbar .navbar-brand span {
        display: none;
        /* hide text, keep icon */
    }

    /* Admin name hidden on mobile (already d-none d-md-inline) */
}

@media (max-width: 480px) {
    .main-content {
        padding: .75rem;
    }

    .page-header-modern {
        padding: 1rem 1.25rem;
    }

    .page-header-modern h5 {
        font-size: 1.3rem;
    }

    .btn.btn-primary {
        font-size: .82rem;
        padding: .5rem 1rem;
    }
}