/* ========================================
   PRIVATE SELL ADMIN - Light/Dark Theme
   Based on licence-santinbot design
   ======================================== */

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

/* ========== LIGHT MODE (default) ========== */
:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #ffffff;

    --border-primary: #e5e5e5;
    --border-hover: #d4d4d4;
    --border-focus: #3b82f6;

    --text-primary: #171717;
    --text-secondary: #525252;
    --text-muted: #a3a3a3;

    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --accent-muted: rgba(59, 130, 246, 0.1);

    --success: #22c55e;
    --success-muted: rgba(34, 197, 94, 0.1);

    --error: #ef4444;
    --error-muted: rgba(239, 68, 68, 0.1);

    --warning: #f59e0b;

    --icon-color: #525252;

    /* Spacing */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    /* Transitions */
    --transition: 150ms ease;
}

/* ========== DARK MODE ========== */
.dark {
    --bg-primary: #141414;
    --bg-secondary: #1a1a1a;
    --bg-card: #1a1a1a;
    --bg-input: #262626;

    --border-primary: #2e2e2e;
    --border-hover: #404040;
    --border-focus: #3b82f6;

    --text-primary: #f5f5f5;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;

    --accent-primary: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-muted: rgba(59, 130, 246, 0.15);

    --success: #22c55e;
    --success-muted: rgba(34, 197, 94, 0.15);

    --error: #ef4444;
    --error-muted: rgba(239, 68, 68, 0.15);

    --icon-color: #a3a3a3;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Hide cyberpunk backgrounds */
.bg-grid,
.bg-glow,
.scanlines {
    display: none;
}

/* Theme Toggle Button */
.theme-toggle {
    position: absolute;
    top: 32px;
    right: 70px;
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
}

/* Light mode: show moon icon */
:root:not(.dark) .theme-toggle .icon-moon,
body:not(.dark) .theme-toggle .icon-moon {
    display: block;
}

/* Dark mode: show sun icon */
.dark .theme-toggle .icon-sun {
    display: block;
}

.dark .theme-toggle .icon-moon {
    display: none;
}

/* Login Theme Toggle */
.login-theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
}

/* Login Screen */
.login-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: var(--bg-primary);
}

.login-screen.hidden {
    display: none;
}

.login-container {
    text-align: center;
    padding: 48px 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 90%;
    position: relative;
}

.login-form {
    margin-top: 32px;
    text-align: left;
}

.login-error {
    margin-top: 16px;
    padding: 12px;
    background: var(--error-muted);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    color: var(--error);
    font-size: 0.875rem;
    text-align: center;
}

.login-error.hidden {
    display: none;
}

/* Container */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 32px 24px;
    position: relative;
    z-index: 1;
}

.container.hidden {
    display: none;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 32px;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 4px;
}

.logo-icon {
    width: 44px;
    height: 44px;
}

.bot-icon {
    width: 100%;
    height: 100%;
}

.bot-icon rect,
.bot-icon circle {
    transition: stroke 0.3s ease, fill 0.3s ease;
}

.eye {
    animation: none;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-santin {
    color: var(--text-primary);
}

.logo-bot {
    color: var(--accent-primary);
}

.tagline {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Logout Button */
.logout-btn {
    position: absolute;
    top: 32px;
    right: 24px;
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.logout-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.logout-btn svg {
    width: 18px;
    height: 18px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--bg-card);
    padding: 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-sm);
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn svg {
    width: 16px;
    height: 16px;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.tab-btn.active {
    background: var(--accent-primary);
    color: white;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

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

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.card::before {
    display: none;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-primary);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
}

.status-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Form Sections (Checkout+) */
.form-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-primary);
}

.form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 24px;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
}

.input-row {
    display: flex;
    gap: 16px;
}

.input-row .input-group {
    flex: 1;
    margin-bottom: 16px;
}

.input-group.half {
    flex: 1;
}

.input-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

textarea.cyber-input {
    resize: vertical;
    min-height: 60px;
    font-family: 'Inter', sans-serif;
}

/* Input Group */
.input-group {
    margin-bottom: 20px;
}

.input-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.cyber-input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    transition: var(--transition);
}

.cyber-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.cyber-input::placeholder {
    color: var(--text-muted);
}

.cyber-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23525252' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 44px;
}

.dark .cyber-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23a3a3a3' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.phone-input-wrapper {
    display: flex;
    align-items: stretch;
}

.country-code {
    display: flex;
    align-items: center;
    padding: 0 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-right: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
}

.phone-input-wrapper .cyber-input {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Buttons */
.cyber-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.cyber-btn:hover {
    background: var(--accent-hover);
}

.cyber-btn.primary {
    width: 100%;
    padding: 14px 20px;
}

.cyber-btn.small {
    padding: 8px 14px;
    font-size: 0.8125rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.cyber-btn.small:hover {
    background: var(--bg-primary);
    border-color: var(--border-hover);
}

.cyber-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

.btn-glow {
    display: none;
}

/* Result Box */
.result-box {
    margin-top: 24px;
    padding: 20px;
    background: var(--success-muted);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: var(--radius-md);
}

.result-box.hidden {
    display: none;
}

.result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--success);
    margin-bottom: 16px;
}

.result-header svg {
    width: 20px;
    height: 20px;
    stroke: var(--success);
}

.result-row {
    margin-bottom: 14px;
}

.result-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.url-box {
    display: flex;
    gap: 8px;
}

.url-box input {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
}

.copy-btn {
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.copy-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.copy-btn svg {
    width: 16px;
    height: 16px;
}

.result-details {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.result-details p {
    margin-bottom: 4px;
}

.result-details strong {
    color: var(--text-primary);
}

.original-price {
    color: var(--text-muted);
    text-decoration: line-through;
}

/* Checkout List */
.checkout-list {
    max-height: 520px;
    overflow-y: auto;
    margin: 20px 0;
}

.checkout-list::-webkit-scrollbar {
    width: 6px;
}

.checkout-list::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 3px;
}

.checkout-list::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 3px;
}

.checkout-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.checkout-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    transition: var(--transition);
}

.checkout-item:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.checkout-item.inactive {
    opacity: 0.5;
}

.checkout-info {
    flex: 1;
    min-width: 0;
}

.checkout-phone {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 2px;
}

.checkout-product {
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.checkout-price {
    text-align: right;
    min-width: 80px;
}

.checkout-price .price {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--success);
}

.checkout-price .original {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: line-through;
}

.checkout-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 60px;
}

.stat-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
}

.stat-badge.used {
    background: var(--error-muted);
    color: var(--error);
    border-color: rgba(239, 68, 68, 0.3);
}

.checkout-actions {
    display: flex;
    gap: 6px;
}

.action-btn {
    padding: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.action-btn.delete:hover {
    border-color: var(--error);
    color: var(--error);
    background: var(--error-muted);
}

.action-btn svg {
    width: 14px;
    height: 14px;
}

/* Search */
.search-box {
    margin-bottom: 16px;
}

/* Refresh Button */
.refresh-btn {
    padding: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.refresh-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.refresh-btn:active svg {
    animation: spin 0.5s linear;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.refresh-btn svg {
    width: 16px;
    height: 16px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}

.page-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Loading */
.loading {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    transition: var(--transition);
}

.toast.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(8px);
}

.toast.success {
    border-color: var(--success);
    background: var(--success-muted);
    color: var(--success);
}

.toast.error {
    border-color: var(--error);
    background: var(--error-muted);
    color: var(--error);
}

/* Footer */
.footer {
    margin-top: 48px;
    text-align: center;
}

.footer-line {
    height: 1px;
    background: var(--border-primary);
    margin-bottom: 20px;
}

.copyright {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    stroke: var(--text-muted);
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Notes Tab */
.notes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.notes-table-container {
    max-height: 450px;
    overflow-y: auto;
}

.notes-table-container::-webkit-scrollbar {
    width: 6px;
}

.notes-table-container::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 3px;
}

.notes-table-container::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 3px;
}

.notes-table {
    width: 100%;
    border-collapse: collapse;
}

.notes-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border-primary);
    position: sticky;
    top: 0;
    background: var(--bg-card);
}

.notes-table th:first-child {
    width: 60px;
}

.notes-table th:last-child {
    width: 50px;
}

.notes-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-primary);
    font-size: 0.875rem;
}

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

.notes-table tr:hover {
    background: var(--bg-primary);
}

.notes-table .note-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent-primary);
    background: var(--accent-muted);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.notes-table .note-date {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.notes-table .note-text {
    color: var(--text-primary);
    max-width: 300px;
    word-break: break-word;
}

.notes-table .copy-note-btn {
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.notes-table .copy-note-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-muted);
}

.notes-table .copy-note-btn svg {
    width: 14px;
    height: 14px;
}

/* Auto-refresh toggle */
.auto-refresh-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.toggle-text {
    font-size: 0.75rem;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 20px 16px;
    }

    .logo-text {
        font-size: 1.25rem;
    }

    .tabs {
        flex-direction: column;
    }

    .tab-btn {
        padding: 10px 16px;
        font-size: 0.8125rem;
    }

    .card {
        padding: 20px;
    }

    .input-row {
        flex-direction: column;
        gap: 0;
    }

    .input-row .input-group {
        margin-bottom: 20px;
    }

    .checkout-item {
        flex-wrap: wrap;
    }

    .checkout-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 12px;
    }

    .theme-toggle {
        right: 60px;
        top: 24px;
    }

    .logout-btn {
        top: 24px;
        right: 16px;
    }

    .notes-grid {
        grid-template-columns: 1fr;
    }
}
