/**
 * TudoB2B OTP Admin - Styles
 * Based on BRAND.md guidelines
 */

/* ========== CSS Variables ========== */
:root {
    /* Primary */
    --color-primary: #26486A;
    --color-primary-light: #26486A;
    --color-accent: #19A885;

    /* Neutral */
    --color-white: #FFFFFF;
    --color-gray-100: #F8F9FA;
    --color-gray-200: #EDEFF2;
    --color-gray-500: #6C757D;
    --color-gray-900: #0A1128;

    /* States */
    --color-success: #28A745;
    --color-error: #B23B3B;
    --color-warning: #FFC107;
    --color-info: #17A2B8;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-xxl: 48px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

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

    /* Typography */
    --font-headline: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-gray-900);
    background-color: var(--color-gray-100);
}
h1, h2, h3 {
    font-family: var(--font-headline);
    font-weight: 700;
}

/* ========== Layout ========== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--color-primary);
    color: var(--color-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: var(--space-lg);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.sidebar-logo img {
    height: 40px;
    width: auto;
}

.sidebar-logo h1 {
    font-family: var(--font-headline);
    font-size: 18px;
    font-weight: 700;
}

.sidebar-logo span {
    font-size: 12px;
    color: var(--color-accent);
    display: block;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-md) 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.2s;
    gap: var(--space-sm);
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: var(--color-white);
}

.nav-item.active {
    background: var(--color-primary-light);
    color: var(--color-white);
    border-left: 3px solid var(--color-accent);
}

.nav-item i {
    width: 20px;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: var(--space-lg);
}

/* Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.page-title {
    font-family: var(--font-headline);
    font-size: 24px;
    font-weight: 700;
    color: var(--color-gray-900);
}

/* ========== Cards ========== */
.card {
    background: var(--color-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-gray-200);
}

.card-title {
    font-family: var(--font-headline);
    font-size: 18px;
    font-weight: 600;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.stat-card {
    background: var(--color-white);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.stat-card.primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    color: var(--color-white);
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.stat-label {
    font-size: 14px;
    color: var(--color-gray-500);
}

.stat-card.primary .stat-label {
    color: rgba(255,255,255,0.8);
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

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

.btn-secondary {
    background: var(--color-gray-200);
    color: var(--color-gray-900);
}

.btn-secondary:hover {
    background: var(--color-gray-500);
    color: var(--color-white);
}

.btn-success {
    background: var(--color-success);
    color: var(--color-white);
}

.btn-danger {
    background: var(--color-error);
    color: var(--color-white);
}

.btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: 12px;
}

/* ========== Forms ========== */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    margin-bottom: var(--space-xs);
    font-weight: 500;
    color: var(--color-gray-900);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-size: 14px;
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(152, 193, 217, 0.2);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
}

/* ========== Tables ========== */
.table-container {
    overflow-x: auto;
}

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

.table th,
.table td {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--color-gray-200);
}

.table th {
    font-weight: 600;
    color: var(--color-gray-500);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background: var(--color-gray-100);
}

/* ========== Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.badge-success {
    background: rgba(40, 167, 69, 0.1);
    color: var(--color-success);
}

.badge-error {
    background: rgba(220, 53, 69, 0.1);
    color: var(--color-error);
}

.badge-warning {
    background: rgba(255, 193, 7, 0.1);
    color: #856404;
}

.badge-info {
    background: rgba(23, 162, 184, 0.1);
    color: var(--color-info);
}

/* ========== Modal ========== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-20px);
    transition: transform 0.3s;
}

.modal-backdrop.show .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--color-gray-200);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-gray-500);
}

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-lg);
    border-top: 1px solid var(--color-gray-200);
}

/* ========== Alerts ========== */
.alert {
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.alert-success {
    background: rgba(40, 167, 69, 0.1);
    color: var(--color-success);
    border-left: 3px solid var(--color-success);
}

.alert-error {
    background: rgba(220, 53, 69, 0.1);
    color: var(--color-error);
    border-left: 3px solid var(--color-error);
}

.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    color: #856404;
    border-left: 3px solid var(--color-warning);
}

/* ========== Page Sections ========== */
.page-section {
    display: none;
}

.page-section.active {
    display: block;
}

/* ========== Utilities ========== */
.text-muted { color: var(--color-gray-500); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-md { margin-top: var(--space-md); }
.mb-md { margin-bottom: var(--space-md); }
.hidden { display: none !important; }

/* ========== Loading ========== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xxl);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-gray-200);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-gray-200);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: '';
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--color-accent);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-group .form-label {
    margin-bottom: 0;
}
