/* 
  Admin Dashboard Custom Styles
  Kapper's Barbershop - Responsive & Functional
*/

/* =========================================
   Layout: Admin Body
========================================= */
.admin-body {
    display: flex;
    background-color: var(--bg-tertiary);
    min-height: 100vh;
}

/* =========================================
   Sidebar
========================================= */
.sidebar {
    width: 270px;
    background-color: var(--bg-primary);
    border-right: 1px solid var(--border-light);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 2000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

/* Sidebar Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.08em;
    line-height: 1.2;
}

/* Sidebar Profile */
.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem 1rem;
    flex-shrink: 0;
}

.profile-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-light);
    flex-shrink: 0;
}

.profile-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.profile-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.profile-status {
    font-size: 0.7rem;
    color: #22c55e;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.15rem;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Sidebar Category & Menu */
.sidebar-category {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    padding: 0.75rem 1.5rem 0.5rem;
    text-transform: uppercase;
    flex-shrink: 0;
}

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-menu li a i {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.sidebar-menu li a:hover,
.sidebar-menu li.active a {
    color: var(--accent-color);
    background-color: var(--bg-secondary);
    border-right: 3px solid var(--accent-color);
}

/* Sidebar Promo Card */
.sidebar-card {
    margin: auto 1rem 0;
    padding: 1.25rem;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    text-align: center;
    flex-shrink: 0;
}

.sidebar-card i {
    font-size: 1.75rem;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
    display: block;
}

.sidebar-card h4 {
    font-size: 1rem;
    margin-bottom: 0.35rem;
}

.sidebar-card p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* =========================================
   Main Content Area
========================================= */
.admin-content {
    margin-left: 270px;
    width: calc(100% - 270px);
    padding: 2rem 2.5rem;
    min-height: 100vh;
}

.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.admin-topbar > div:first-child {
    flex: 1;
    min-width: 200px;
}

.page-title {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.admin-topbar > div:first-child > p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

/* =========================================
   Dashboard Stats Grid
========================================= */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--bg-primary);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.stat-card > i,
.stat-card > .stat-icon {
    font-size: 2rem;
    color: var(--accent-color);
    background-color: var(--bg-secondary);
    padding: 0.85rem;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.sc-info h3,
.stat-info .stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
}

.stat-info h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

/* =========================================
   Data Table
========================================= */
.table-container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.data-table th,
.data-table td {
    padding: 1rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

.data-table td {
    white-space: normal;
    word-break: break-word;
}

.data-table th {
    background-color: var(--bg-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 1;
    white-space: nowrap;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background-color: var(--bg-secondary);
}

/* =========================================
   Status Badges
========================================= */
.status {
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
    white-space: nowrap;
}

.status.pending {
    background-color: #FEF08A;
    color: #854D0E;
}

.status.completed {
    background-color: #BBF7D0;
    color: #166534;
}

.status.cancelled {
    background-color: #FECDD3;
    color: #9F1239;
}

/* =========================================
   Action Buttons
========================================= */
.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

/* =========================================
   Tab Navigation System (SPA)
========================================= */
.tab-content {
    display: none;
    animation: adminFadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

@keyframes adminFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================
   Modal (Kasir / POS)
========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 1rem;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
    animation: adminFadeIn 0.3s;
}

.modal-card {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    border: 1px solid var(--border-light);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-height: 90vh;
    overflow-y: auto;
}

#pos-product-list {
    margin: 0;
}

#pos-product-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border-light);
}

/* =========================================
   Mobile Header
========================================= */
.admin-mobile-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-primary);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    margin: -2rem -2.5rem 2rem -2.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-mobile-header h2 {
    font-size: 1.2rem;
    margin: 0;
}

/* Mobile overlay backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* =========================================
   Form Helpers
========================================= */
.form-inline-add {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-inline-add .form-control {
    flex: 1;
    min-width: 120px;
}

.form-inline-add .btn {
    flex-shrink: 0;
}

/* =========================================
   Responsive: Tablet (≤ 1200px)
========================================= */
@media (max-width: 1200px) {
    .admin-content {
        padding: 2rem 2rem;
    }

    .admin-mobile-header {
        margin: -2rem -2rem 2rem -2rem;
    }
}

/* =========================================
   Responsive: ≤ 992px (Mobile Sidebar)
========================================= */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.15);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .admin-content {
        margin-left: 0;
        width: 100%;
        padding: 2rem 1.25rem;
    }

    .admin-mobile-header {
        display: flex;
        margin: -2rem -1.25rem 1.5rem -1.25rem;
    }

    .admin-topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .admin-topbar > div:first-child {
        width: 100%;
    }

    /* Only target direct button children for full-width on mobile */
    .admin-topbar > .btn,
    .admin-topbar > div:last-child {
        width: 100%;
    }

    .admin-topbar > div:last-child {
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .admin-topbar > div:last-child > .btn {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }

    .page-title {
        font-size: 1.4rem;
    }
}

/* =========================================
   Responsive: ≤ 768px (Mobile)
========================================= */
@media (max-width: 768px) {
    .admin-content {
        padding: 1.5rem 1rem;
    }

    .admin-mobile-header {
        margin: -1.5rem -1rem 1.25rem -1rem;
    }

    .dashboard-stats {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    /* Horizontal table scrolling for all tables */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }

    .modal-card {
        padding: 1.25rem;
        border-radius: var(--radius-md);
    }

    .page-title {
        font-size: 1.25rem;
    }
}

/* =========================================
   Responsive: ≤ 480px (Small Phone)
========================================= */
@media (max-width: 480px) {
    .admin-content {
        padding: 1.25rem 0.75rem;
    }

    .admin-mobile-header {
        margin: -1.25rem -0.75rem 1rem -0.75rem;
        padding: 0.75rem 1rem;
    }

    .stat-card {
        padding: 0.85rem;
        gap: 0.75rem;
    }

    .stat-card > i,
    .stat-card > .stat-icon {
        font-size: 1.5rem;
        padding: 0.65rem;
    }

    .sc-info h3,
    .stat-info .stat-number {
        font-size: 1.25rem;
    }

    .data-table {
        min-width: 450px;
    }

    .data-table th,
    .data-table td {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
    }

    .modal-card {
        padding: 1rem;
    }
}

/* =========================================
   Print Styles (Thermal Printer 58mm/80mm)
========================================= */
#print-area {
    display: none;
}

@media print {
    body * {
        display: none !important;
    }

    #print-area,
    #print-area * {
        display: block !important;
    }

    #print-area {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-width: 80mm;
        margin: 0;
        padding: 0;
        font-family: monospace;
        font-size: 12px;
        color: black;
    }

    .print-center {
        text-align: center !important;
    }

    .print-right {
        text-align: right !important;
    }

    .print-flex {
        display: flex !important;
        justify-content: space-between !important;
    }

    .print-flex span {
        display: inline-block !important;
    }

    .print-line {
        border-bottom: 1px dashed black !important;
        margin: 5px 0 !important;
    }
}
