/* ===== VARIABLES ===== */
:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --success: #48bb78;
    --danger: #fc8181;
    --warning: #ed8936;
    --info: #4299e1;
    --dark: #1a202c;
    --gray-900: #1a202c;
    --gray-800: #2d3748;
    --gray-700: #4a5568;
    --gray-600: #718096;
    --gray-500: #a0aec0;
    --gray-400: #cbd5e0;
    --gray-300: #e2e8f0;
    --gray-200: #edf2f7;
    --gray-100: #f7fafc;
    --white: #ffffff;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== NAVBAR ===== */
.navbar {
    background: var(--white);
    box-shadow: var(--shadow);
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--gray-800);
    font-weight: 700;
    font-size: 1.1rem;
}

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

.nav-menu {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    text-decoration: none;
    color: var(--gray-600);
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--white);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    font-size: 0.9rem;
    color: var(--gray-700);
}

.country-badge {
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-left: 4px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    padding: 24px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.8rem;
    color: var(--gray-800);
}

.page-header .subtitle {
    color: var(--gray-600);
    margin-top: 4px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--white);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

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

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

.btn-outline {
    background: var(--white);
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 8px;
}

.btn-option {
    background: var(--white);
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
    flex: 1;
}

.btn-option.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-color: transparent;
    color: var(--white);
}

/* ===== CARDS ===== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 1.1rem;
    color: var(--gray-800);
}

.card-body {
    padding: 24px;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

/* ===== TABLES ===== */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

.table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.table tfoot .total-row {
    background: var(--gray-100);
    font-weight: 600;
}

.inline-form {
    display: inline;
}

/* ===== STATUS BADGES ===== */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-new {
    background: #ebf8ff;
    color: #2b6cb0;
}

.status-processing {
    background: #faf5ff;
    color: #6b46c1;
}

.status-completed {
    background: #f0fff4;
    color: #276749;
}

.status-cancelled {
    background: #fff5f5;
    color: #c53030;
}

.status-select {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--gray-300);
    font-size: 0.85rem;
    cursor: pointer;
}

/* ===== ALERTS ===== */
.flash-messages {
    max-width: 1200px;
    margin: 0 auto 16px;
}

.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-success {
    background: #f0fff4;
    border: 1px solid #9ae6b4;
    color: #276749;
}

.alert-error {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    color: #c53030;
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.5;
}

.alert-close:hover {
    opacity: 1;
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.new {
    background: #ebf8ff;
    color: #2b6cb0;
}

.stat-icon.orders {
    background: #faf5ff;
    color: #6b46c1;
}

.stat-icon.products {
    background: #f0fff4;
    color: #276749;
}

.stat-icon.distributors {
    background: #fffaf0;
    color: #c05621;
}

.stat-content .stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--gray-800);
}

.stat-content .stat-label {
    color: var(--gray-600);
    font-size: 0.9rem;
}

/* ===== ORDER FORM ===== */
.order-options {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
}

.option-group {
    flex: 1;
}

.option-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--gray-700);
}

.products-section {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

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

.section-header h2 {
    font-size: 1.1rem;
    color: var(--gray-800);
}

.search-box input {
    padding: 8px 16px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    width: 250px;
}

.products-table .qty-col {
    width: 140px;
}

.qty-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 600;
}

.qty-input:focus {
    outline: none;
    border-color: var(--primary);
}

.order-summary {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-200);
}

.summary-row:last-child {
    border: none;
}

.loading-row td,
.error-row td,
.empty-row td {
    text-align: center;
    padding: 40px;
    color: var(--gray-500);
}

/* ===== ORDER DETAIL ===== */
.order-detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.info-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-200);
}

.info-row:last-child {
    border: none;
}

.info-row .label {
    width: 120px;
    font-weight: 600;
    color: var(--gray-600);
}

.info-row .value {
    flex: 1;
    color: var(--gray-800);
}

.summary-stat {
    text-align: center;
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
}

.summary-stat:last-child {
    border: none;
}

.summary-stat .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.summary-stat .stat-label {
    color: var(--gray-600);
    font-size: 0.85rem;
}

/* ===== FILTERS ===== */
.filters-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.filters-form {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
}

.filter-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
}

.filter-group select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
}

/* ===== COUNTRY CHIPS ===== */
.country-chip {
    display: inline-block;
    margin-right: 4px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.empty-state p {
    color: var(--gray-600);
    margin-bottom: 16px;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-box {
    background: var(--white);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    width: 80px;
    height: auto;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 1.5rem;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.login-header p {
    color: var(--gray-600);
}

.login-form .form-group {
    margin-bottom: 16px;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--white);
    padding: 20px;
    text-align: center;
    color: var(--gray-600);
    font-size: 0.85rem;
    border-top: 1px solid var(--gray-200);
}

/* ===== UTILITIES ===== */
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.text-muted { color: var(--gray-500); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .nav-menu {
        display: none;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-grid,
    .form-grid-3,
    .form-grid-4 {
        grid-template-columns: 1fr;
    }

    .order-options {
        flex-direction: column;
    }

    .order-detail-grid {
        grid-template-columns: 1fr;
    }

    .filters-form {
        flex-direction: column;
    }

    .checkbox-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
