/* ==========================================================================
   AI Retail Try-On Platform — 2026 Minimal Admin Design
   Modular: Header | Sidebar | Content | Footer
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Neutral palette */
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-elevated: #ffffff;
    --border: #f0f0f0;
    --border-strong: #e5e5e5;
    --text: #171717;
    --text-secondary: #737373;
    --text-muted: #a3a3a3;
    
    /* Accent - subtle */
    --accent: #0a0a0a;
    --accent-hover: #262626;
    
    /* Semantic */
    --success: #16a34a;
    --success-bg: #dcfce7;
    --warning: #ca8a04;
    --warning-bg: #fef9c3;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --info: #2563eb;
    
    /* Layout */
    --header-h: 64px;
    --sidebar-w: 240px;
    --footer-h: 40px;
    --radius: 6px;
    --radius-sm: 4px;
    
    /* Spacing - 4px grid */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    
    /* Shadow */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ========== LOGIN ========== */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-4);
    background: var(--bg);
}
.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
}
.login-logo {
    text-align: center;
    margin-bottom: var(--space-4);
}
.login-logo img {
    max-width: 216px;
    height: auto;
    object-fit: contain;
}
.login-card .subtitle {
    color: var(--text-secondary);
    margin-bottom: var(--space-5);
    font-size: 0.8125rem;
}
.login-card .form-group { margin-bottom: var(--space-4); }
.login-card label {
    display: block;
    font-weight: 500;
    font-size: 0.8125rem;
    margin-bottom: var(--space-2);
    color: var(--text);
}
.login-card input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-family: inherit;
    background: var(--surface);
}
.login-card input:focus {
    outline: none;
    border-color: var(--text-muted);
    box-shadow: 0 0 0 2px rgba(0,0,0,0.06);
}
.login-card .btn {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    margin-top: var(--space-2);
    font-size: 0.875rem;
}
.login-card .alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-4);
    font-size: 0.8125rem;
}
.login-card .alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #fecaca;
}

/* ========== APP LAYOUT ========== */
.app-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ----- SIDEBAR ----- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, width 0.2s ease;
}
.sidebar.collapsed { transform: translateX(-100%); }
.sidebar-header {
    height: var(--header-h);
    min-height: var(--header-h);
    padding: 0 var(--space-4);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
}
.sidebar .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    width: 100%;
    height: 58px;
}
.sidebar .logo img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}
.sidebar-toggle {
    display: none;
    position: absolute;
    right: var(--space-2);
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-2);
    color: var(--text-secondary);
}
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2) 0;
}
.nav-group {
    margin-bottom: var(--space-4);
}
.nav-group:last-child { margin-bottom: 0; }
.nav-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #6b7280);
    padding: var(--space-1) var(--space-4);
    margin: 0 var(--space-2) var(--space-2);
    border-bottom: 1px solid var(--border);
}
.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    margin: 0 var(--space-2);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}
.nav-item:hover {
    background: var(--bg);
    color: var(--text);
}
.nav-item.active {
    background: var(--bg);
    color: var(--text);
}
.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}
.nav-item.active .nav-icon { opacity: 1; }

/* ----- HEADER ----- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.top-header {
    position: sticky;
    top: 0;
    height: var(--header-h);
    min-height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    gap: var(--space-4);
    z-index: 100;
}
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-2);
    color: var(--text);
}
.header-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text);
    letter-spacing: -0.01em;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 0.8125rem;
}
.header-profile-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
}
.header-avatar, .header-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}
.header-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
}
.header-user-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.3;
}
.header-user-block .user-info { font-weight: 500; color: var(--text); }
.header-user-block .user-role {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 1px;
}

/* ----- CONTENT ----- */
.content-area {
    flex: 1;
    padding: var(--space-5);
    padding-bottom: calc(var(--footer-h) + var(--space-5));
}

/* ----- FOOTER ----- */
.app-footer {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-w);
    right: 0;
    height: var(--footer-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    z-index: 50;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-outline:hover {
    background: var(--bg);
    border-color: var(--text-muted);
}
.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: var(--space-1) var(--space-3); font-size: 0.75rem; }

/* ========== CARDS ========== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}
.card-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.card-body { padding: var(--space-4); }

/* Ticket view */
.ticket-view .card { margin-bottom: var(--space-6); }
.ticket-view .card-body {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-secondary);
}
.ticket-view .card-body label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text);
}
.ticket-view .card-body .form-control {
    font-size: 0.8125rem;
}
.ticket-view .card-body p {
    margin: 0.125em 0;
    color: var(--text-secondary);
}
.ticket-view .card-body p strong {
    color: var(--text);
    font-weight: 600;
}
.ticket-view .card-body .ticket-reply {
    font-size: 0.8125rem;
    padding: var(--space-3);
}
.ticket-view .card-body .ticket-reply strong {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
}
.ticket-view .card-body .ticket-reply-text {
    margin: 0.375rem 0 0;
    color: var(--text-secondary);
}
.ticket-view .card-body .ticket-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.ticket-view .card-header {
    font-size: 0.8125rem;
}
.ticket-closed-notice {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}
.ticket-view .card-body > * + * { margin-top: var(--space-3); }
.ticket-view .card-body > .form-group { margin-top: var(--space-4); }
.ticket-filters-form .filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    align-items: flex-start;
}
.ticket-filters-form .filter-row .form-group {
    margin-bottom: 0;
    min-width: 140px;
}
.ticket-filters-form .filter-row .form-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}
.ticket-filters-form .form-control-sm {
    padding: var(--space-1) var(--space-2);
    font-size: 0.8125rem;
}
.ticket-divider {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    margin: var(--space-4) 0;
}
.ticket-back-btn { margin-top: var(--space-4); display: inline-block; }

/* ========== KPI CARDS ========== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}
.kpi-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: var(--space-4);
    border: 1px solid var(--border);
}
.kpi-card .label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: var(--space-1);
}
.kpi-card .value {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
}

/* ========== TABLES ========== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
th, td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--border);
}
th {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
tr:hover td { background: var(--bg); }
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
}
.status-online { background: var(--success-bg); color: var(--success); }
.text-muted { color: var(--text-muted); }
.status-offline { background: var(--bg); color: var(--text-muted); }
.status-success { background: var(--success-bg); color: var(--success); }
.status-pending { background: var(--warning-bg); color: var(--warning); }
.status-info { background: #e0f2fe; color: #0369a1; }
.status-fail { background: var(--danger-bg); color: var(--danger); }

/* Brand logo display */
.brand-logo-cell {
    width: 96px;
    min-width: 96px;
    padding: var(--space-2);
    vertical-align: middle;
}
.brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.brand-logo img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}
.brand-logo-placeholder {
    width: 80px;
    height: 80px;
    background: var(--border);
    border-radius: var(--radius-sm);
}
.brand-logo-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 140px;
    height: 140px;
    margin-top: var(--space-2);
    padding: var(--space-2);
    background: var(--bg);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.brand-logo-preview img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Brand form - arkaplan & tema renkleri */
.form-text { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: var(--space-1); margin-bottom: var(--space-2); }
.mt-2 { margin-top: var(--space-2); }
.d-block { display: block; }
.brand-bg-preview { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.theme-reset-row { margin-bottom: var(--space-3); }
.theme-colors-simple {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-2);
}
.theme-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.8125rem;
}
.theme-label {
    flex: 1;
    min-width: 0;
    color: var(--text-secondary);
}
.theme-hex {
    width: 32px;
    height: 24px;
    padding: 1px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--surface);
}
.theme-opacity {
    width: 42px;
    font-size: 0.75rem;
    padding: 2px 4px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}

/* Locations page - 3 column layout */
.locations-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    margin-top: var(--space-4);
}
.locations-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.locations-col .card {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}
.locations-col .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.locations-col .locations-list {
    flex: 1;
    overflow: auto;
    max-height: 420px;
    -webkit-overflow-scrolling: touch;
}
.locations-col .locations-list table { font-size: 0.75rem; }
.locations-col .locations-list th, .locations-col .locations-list td { padding: var(--space-2) var(--space-3); }
.locations-col .locations-add { margin-bottom: var(--space-3); flex-shrink: 0; }
.locations-col .locations-add .form-control { font-size: 0.8125rem; }
@media (max-width: 1024px) {
    .locations-grid { grid-template-columns: 1fr; }
    .locations-col .locations-list { max-height: 320px; }
}

/* ========== FORMS ========== */
.form-group { margin-bottom: var(--space-4); }
.form-group label {
    display: block;
    font-weight: 500;
    font-size: 0.8125rem;
    margin-bottom: var(--space-2);
    color: var(--text);
}
.form-control {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--text-muted);
    box-shadow: 0 0 0 2px rgba(0,0,0,0.06);
}
textarea.form-control { min-height: 96px; resize: vertical; }
select.form-control { cursor: pointer; }

/* ========== ALERTS ========== */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-4);
    font-size: 0.8125rem;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #fde68a; }

/* ========== MOBILE NAV ========== */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 150;
    padding: 0 var(--space-2);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 48px;
    padding: var(--space-2);
    font-size: 0.625rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
}
.mobile-nav a:hover, .mobile-nav a.active { color: var(--text); }
.mobile-nav .nav-icon { margin-bottom: 2px; }

/* ========== CHART ========== */
.chart-container {
    height: 220px;
    min-height: 180px;
    position: relative;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    color: var(--text-muted);
    font-size: 0.875rem;
}
.empty-state .icon { font-size: 2rem; margin-bottom: var(--space-3); opacity: 0.4; }

/* ========== PAGINATION ========== */
.pagination {
    display: flex;
    gap: var(--space-1);
    margin-top: var(--space-4);
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}
.pagination a:hover { background: var(--bg); }
.pagination .current { background: var(--accent); color: white; border-color: var(--accent); }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
        box-shadow: var(--shadow-md);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: flex; flex-direction: column; gap: 4px; }
    .main-content { margin-left: 0; }
    .mobile-menu-btn { display: flex; }
    .mobile-nav {
        display: flex;
        align-items: center;
        justify-content: space-around;
    }
    .content-area {
        padding-bottom: calc(72px + var(--space-5));
    }
    .app-footer {
        display: none;
    }
    .header-actions .header-user-block .user-role { display: none; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
}

@media (min-width: 769px) {
    .mobile-nav { display: none !important; }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .content-area { padding: var(--space-4); }
    th, td { padding: var(--space-2) var(--space-3); font-size: 0.75rem; }
}

/* Product list thumbnails */
.product-image-cell { width: 56px; }
.product-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.product-thumb-placeholder {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.75rem;
}
