/**
 * Mystery Client System - Custom Styles
 * Pinalli Beauty Store
 */

/* Theme colors and fonts are injected via PHP (theme.json → theme.php → header.php)
   Only layout variables are defined here as fallbacks */
:root {
    --sidebar-width: 260px;
    --navbar-height: 60px;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--background);
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--sidebar-bg-start) 0%, var(--sidebar-bg-end) 100%);
    color: #fff;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
    color: #fff;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.sidebar-brand:hover {
    color: #fff;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
}

.sidebar-nav {
    padding: 1rem 0;
}

.sidebar-nav .nav-link {
    color: rgba(255,255,255,0.7);
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link i {
    width: 24px;
    margin-right: 0.75rem;
    text-align: center;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-left-color: var(--sidebar-active);
}

.sidebar-nav .collapse .nav-link {
    padding-left: 2rem;
    font-size: 0.9rem;
}

.sidebar-nav hr {
    border-color: rgba(255,255,255,0.1);
    margin: 1rem 1.25rem;
}

/* Top Navbar */
.top-navbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--navbar-height);
    z-index: 999;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.top-navbar .btn-link {
    color: #6c757d;
    text-decoration: none;
}

.top-navbar .btn-link:hover {
    color: var(--primary);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    padding-top: var(--navbar-height);
    min-height: 100vh;
}

.main-content > .container-fluid {
    padding: 1.5rem;
}

/* Footer */
.footer {
    margin-left: var(--sidebar-width);
    border-top: 1px solid #dee2e6;
}

/* Mobile Responsive */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .top-navbar,
    .main-content,
    .footer {
        margin-left: 0;
        left: 0;
    }
}

/* Notifications Dropdown */
.notification-dropdown {
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
}

.notification-list .dropdown-item {
    white-space: normal;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.notification-list .dropdown-item:last-child {
    border-bottom: none;
}

.notification-list .dropdown-item.unread {
    background-color: #f8f9ff;
}

.notification-list .notification-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

/* Cards */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.card-header {
    background: none;
    border-bottom: 1px solid #f0f0f0;
    padding: 1rem 1.25rem;
}

/* KPI Cards */
.kpi-card {
    border-radius: 12px;
    padding: 1.5rem;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 100px;
    height: 100px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.kpi-card .kpi-icon {
    font-size: 2.5rem;
    opacity: 0.7;
}

.kpi-card .kpi-value {
    font-size: 2rem;
    font-weight: 700;
}

.kpi-card .kpi-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

.kpi-card.bg-primary-gradient {
    background: linear-gradient(135deg, var(--kpi-gradient-start) 0%, var(--kpi-gradient-end) 100%);
}

.kpi-card.bg-success-gradient {
    background: linear-gradient(135deg, var(--success) 0%, #2ecc71 100%);
}

.kpi-card.bg-warning-gradient {
    background: linear-gradient(135deg, var(--warning) 0%, #f1c40f 100%);
}

.kpi-card.bg-danger-gradient {
    background: linear-gradient(135deg, var(--danger) 0%, #c0392b 100%);
}

.kpi-card.bg-info-gradient {
    background: linear-gradient(135deg, var(--info) 0%, #2980b9 100%);
}

/* Tables */
.table {
    margin-bottom: 0;
}

.table thead th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
}

.table tbody tr:hover {
    background-color: #f8f9ff;
}

.table .badge {
    font-weight: 500;
}

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* Forms */
.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 0.625rem 0.875rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--primary-rgb), 0.25);
}

.form-label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.5rem;
}

.input-group-text {
    border-radius: 8px;
    background-color: #f8f9fa;
}

/* Login Page */
.login-page {
    background: linear-gradient(135deg, var(--login-gradient-start) 0%, var(--login-gradient-end) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo i {
    font-size: 3rem;
    color: var(--primary);
}

.login-logo h1 {
    font-size: 1.5rem;
    margin-top: 0.5rem;
    color: #333;
}

/* Multi-step Form */
.step-progress {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    position: relative;
}

.step-progress::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 0;
    right: 0;
    height: 2px;
    background: #e9ecef;
    z-index: 0;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e9ecef;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.step-item.active .step-number {
    background: var(--primary);
    color: #fff;
}

.step-item.completed .step-number {
    background: var(--success);
    color: #fff;
}

.step-label {
    font-size: 0.75rem;
    color: #6c757d;
    text-align: center;
}

.step-item.active .step-label {
    color: var(--primary);
    font-weight: 600;
}

.step-item.step-clickable {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.step-item.step-clickable:hover {
    transform: scale(1.1);
}

.step-item.step-clickable:hover .step-number {
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.3);
}

/* Score Slider */
.score-slider {
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #e74c3c 0%, #f39c12 50%, #27ae60 100%);
    outline: none;
}

.score-slider::-webkit-slider-thumb {
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.score-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 45px;
    text-align: center;
    white-space: nowrap;
}

.score-label-badge {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Chart containers */
.chart-container {
    position: relative;
    height: 300px;
}

/* Photo Gallery */
.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.photo-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-item .photo-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.photo-item:hover .photo-overlay {
    opacity: 1;
}

.photo-item .photo-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.photo-item:hover .photo-delete {
    opacity: 1;
}

/* Upload Area */
.upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background-color: rgba(var(--primary-rgb), 0.05);
}

.upload-area i {
    font-size: 3rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

.upload-area:hover i {
    color: var(--primary);
}

/* Score Badge */
.score-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
}

.score-badge.excellent {
    background-color: rgba(39, 174, 96, 0.15);
    color: #27ae60;
}

.score-badge.good {
    background-color: rgba(52, 152, 219, 0.15);
    color: #3498db;
}

.score-badge.average {
    background-color: rgba(243, 156, 18, 0.15);
    color: #f39c12;
}

.score-badge.poor {
    background-color: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

/* Accordion */
.accordion-button:not(.collapsed) {
    background-color: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.accordion-button:focus {
    box-shadow: none;
    border-color: rgba(var(--primary-rgb), 0.25);
}

/* Toast */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1100;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner-custom {
    width: 48px;
    height: 48px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

/* Tablet (992px and below) */
@media (max-width: 991.98px) {
    :root {
        --sidebar-width: 0;
    }
    
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    /* Overlay when sidebar is open */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    .top-navbar,
    .main-content,
    .footer {
        margin-left: 0 !important;
        left: 0 !important;
    }
    
    .main-content > .container-fluid {
        padding: 1rem;
    }
}

/* Mobile (768px and below) */
@media (max-width: 767.98px) {
    /* Typography */
    h1, .h1 { font-size: 1.75rem; }
    h2, .h2 { font-size: 1.5rem; }
    h3, .h3 { font-size: 1.25rem; }
    
    /* KPI Cards */
    .kpi-card {
        padding: 1rem;
    }
    
    .kpi-card .kpi-value {
        font-size: 1.5rem;
    }
    
    .kpi-card .kpi-icon {
        font-size: 2rem;
    }
    
    /* Step Progress - Compact */
    .step-progress {
        overflow-x: auto;
        padding-bottom: 0.5rem;
        margin-bottom: 1rem;
        gap: 0.25rem;
    }
    
    .step-item {
        min-width: auto;
        flex-shrink: 0;
    }
    
    .step-number {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
    
    .step-label {
        display: none;
    }
    
    /* Login Card */
    .login-card {
        margin: 1rem;
        padding: 1.5rem;
        max-width: 100%;
        border-radius: 12px;
    }
    
    .login-logo img {
        max-width: 150px !important;
    }
    
    .login-logo h1 {
        font-size: 1.25rem;
    }
    
    /* Tables - Horizontal Scroll */
    .table-responsive {
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
        white-space: nowrap;
    }
    
    /* Stack table actions vertically */
    .table .btn-group {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .table .btn-group .btn {
        width: 100%;
    }
    
    /* Cards */
    .card {
        border-radius: 8px;
    }
    
    .card-header,
    .card-body,
    .card-footer {
        padding: 1rem;
    }
    
    /* Buttons - Touch Friendly */
    .btn {
        padding: 0.625rem 1rem;
        min-height: 44px; /* Apple's recommended touch target */
    }
    
    .btn-sm {
        min-height: 36px;
        padding: 0.375rem 0.75rem;
    }
    
    /* Forms */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
    
    .form-label {
        font-size: 0.875rem;
    }
    
    /* Stack form rows on mobile */
    .row.g-3 > [class*="col-md-"],
    .row.g-4 > [class*="col-md-"] {
        margin-bottom: 0.75rem;
    }
    
    /* Score Slider - Touch Friendly */
    .score-slider {
        height: 12px;
    }
    
    .score-slider::-webkit-slider-thumb {
        width: 32px;
        height: 32px;
    }
    
    .score-value {
        font-size: 1.25rem;
        min-width: 45px;
        text-align: center;
        white-space: nowrap;
    }
    
    /* Photo Gallery */
    .photo-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    /* Upload Area */
    .upload-area {
        padding: 1.5rem 1rem;
    }
    
    .upload-area i {
        font-size: 2rem;
    }
    
    /* Notifications */
    .notification-dropdown {
        width: 100vw;
        max-width: 100vw;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        border-radius: 0;
        position: fixed !important;
        top: var(--navbar-height) !important;
    }
    
    /* Charts - Smaller Height */
    .chart-container {
        height: 250px;
    }
    
    /* Accordion */
    .accordion-button {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Page Header - Only direct child of container-fluid */
    .container-fluid > .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: stretch !important;
        gap: 1rem;
    }
    
    .container-fluid > .d-flex.justify-content-between.align-items-center.mb-4 > div:last-child {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .container-fluid > .d-flex.justify-content-between.align-items-center.mb-4 > div:last-child .btn {
        width: 100%;
    }
    
    /* KPI Cards - ensure proper layout */
    .kpi-card .d-flex {
        flex-direction: row !important;
    }
    
    /* Filter Cards */
    .card .row.g-3 {
        flex-direction: column;
    }
    
    /* Empty State */
    .empty-state {
        padding: 2rem 1rem;
    }
    
    .empty-state i {
        font-size: 3rem;
    }
    
    /* Footer */
    .footer {
        padding: 1rem;
        text-align: center;
    }
    
    .footer .d-flex {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Small Mobile (480px and below) */
@media (max-width: 479.98px) {
    .main-content > .container-fluid {
        padding: 0.75rem;
    }
    
    .login-card {
        margin: 0.5rem;
        padding: 1.25rem;
    }
    
    .kpi-card .kpi-value {
        font-size: 1.25rem;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        border-radius: 8px !important;
        margin-bottom: 0.25rem;
    }
    
    /* Report detail - stack columns */
    .col-lg-4,
    .col-lg-8 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .photo-gallery {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .btn:hover {
        transform: none;
    }
    
    .table tbody tr:hover {
        background-color: transparent;
    }
    
    /* Larger touch targets */
    .sidebar-nav .nav-link {
        padding: 1rem 1.25rem;
    }
    
    .dropdown-item {
        padding: 0.75rem 1rem;
    }
    
    /* Disable hover overlays */
    .photo-item .photo-overlay {
        display: none;
    }
}

/* Landscape Mode on Mobile */
@media (max-width: 767.98px) and (orientation: landscape) {
    .login-page {
        padding: 1rem;
    }
    
    .login-card {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .chart-container {
        height: 200px;
    }
}

/* Safe Area Insets for Notched Phones */
@supports (padding: max(0px)) {
    .main-content {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .sidebar {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* Dark Mode Support (optional) */
@media (prefers-color-scheme: dark) {
    /* Uncomment to enable dark mode
    :root {
        --background: #1a1a2e;
    }
    
    body {
        background-color: var(--background);
        color: #e0e0e0;
    }
    
    .card {
        background: #16213e;
        color: #e0e0e0;
    }
    */
}

/* Print styles */
@media print {
    .sidebar,
    .top-navbar,
    .btn,
    .no-print {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
        padding-top: 0;
    }
}
