/**
 * ARBEX SUMAL - Main Stylesheet
 * =============================
 * Common styles for all pages
 */

/* =============================================================================
   CSS RESET & BASE
   ============================================================================= */

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f1f5f9;
    min-height: 100vh;
    color: #1f2937;
    line-height: 1.5;
}

/* =============================================================================
   COLORS (CSS Variables)
   ============================================================================= */

:root {
    /* Brand colors */
    --color-primary: #15803d;
    --color-primary-light: #4ade80;
    --color-accent: #f97316;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #15803d 0%, #4ade80 100%);
    --gradient-admin: linear-gradient(135deg, #dc2626 0%, #f97316 100%);

    /* Text colors */
    --color-text: #1f2937;
    --color-text-muted: #64748b;
    --color-text-light: #9ca3af;

    /* Background colors */
    --color-bg: #f1f5f9;
    --color-bg-white: #ffffff;
    --color-bg-dark: #1a2e1a;

    /* Border colors */
    --color-border: #e5e7eb;
    --color-border-light: #f3f4f6;

    /* Status colors */
    --color-success: #16a34a;
    --color-error: #dc2626;
    --color-warning: #d97706;
    --color-info: #0284c7;

    /* 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 25px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.3);

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

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* =============================================================================
   TYPOGRAPHY
   ============================================================================= */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--color-text);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

a {
    color: var(--color-primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    text-decoration: underline;
}

/* =============================================================================
   FORMS
   ============================================================================= */

.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-text);
    font-weight: 500;
    font-size: 0.875rem;
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color var(--transition-normal), background var(--transition-normal);
    background: var(--color-bg-white);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary-light);
    background: var(--color-bg-white);
}

input::placeholder {
    color: var(--color-text-light);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.hint {
    font-size: 0.75rem;
    color: var(--color-text-light);
    margin-top: 0.25rem;
}

/* =============================================================================
   BUTTONS
   ============================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

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

.btn-primary:hover {
    box-shadow: 0 5px 20px rgba(21, 128, 61, 0.4);
}

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

.btn-admin:hover {
    box-shadow: 0 5px 20px rgba(220, 38, 38, 0.4);
}

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

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

.btn-full {
    width: 100%;
}

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

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* =============================================================================
   ALERTS & MESSAGES
   ============================================================================= */

.error, .alert-error {
    background: #fef2f2;
    color: var(--color-error);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border: 1px solid #fecaca;
}

.success, .alert-success {
    background: #f0fdf4;
    color: var(--color-success);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border: 1px solid #bbf7d0;
}

.warning, .alert-warning {
    background: #fffbeb;
    color: var(--color-warning);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border: 1px solid #fde68a;
}

.info, .alert-info {
    background: #f0f9ff;
    color: var(--color-info);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border: 1px solid #bae6fd;
}

/* =============================================================================
   CARDS & CONTAINERS
   ============================================================================= */

.card {
    background: var(--color-bg-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 2.5rem;
}

.card-sm {
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

/* Auth containers (login, register) */
.auth-container {
    background: var(--color-bg-white);
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 400px;
}

.register-container {
    max-width: 500px;
}

/* Centered page layout for auth */
.auth-page {
    background: var(--gradient-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.admin-auth-page {
    background: var(--gradient-admin);
}

/* =============================================================================
   LOGO
   ============================================================================= */

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

.logo h1 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.logo p {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

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

.logo-sumal {
    color: var(--color-primary-light);
}

/* =============================================================================
   SECTION TITLES
   ============================================================================= */

.section-title {
    font-size: 1rem;
    color: var(--color-primary);
    margin: 1.5rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-border);
}

/* =============================================================================
   LINKS
   ============================================================================= */

.register-link, .login-link {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.register-link a, .login-link a {
    color: var(--color-primary-light);
    font-weight: 500;
}

/* =============================================================================
   BADGES
   ============================================================================= */

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-admin {
    background: #fef3c7;
    color: var(--color-warning);
}

.badge-success {
    background: #dcfce7;
    color: var(--color-success);
}

.badge-error {
    background: #fee2e2;
    color: var(--color-error);
}

/* =============================================================================
   SIDEBAR LAYOUT (Dashboard)
   ============================================================================= */

.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #1a2e1a 0%, #0f1f0f 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.sidebar-logo {
    font-size: 1.5rem;
    font-weight: 700;
}

.sidebar-firma {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 0.25rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 0.5rem;
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    padding: 0.75rem 1.5rem 0.5rem;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all var(--transition-normal);
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    text-decoration: none;
}

.nav-item.active {
    background: rgba(74, 222, 128, 0.1);
    color: var(--color-primary-light);
    border-left-color: var(--color-primary-light);
}

.nav-item .icon {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.nav-item .label {
    font-size: 0.9rem;
    font-weight: 500;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.user-info {
    flex: 1;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
}

.user-role {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.btn-logout {
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    text-decoration: none;
}

/* =============================================================================
   MAIN CONTENT
   ============================================================================= */

.main-content {
    flex: 1;
    margin-left: 260px;
}

.top-header {
    background: var(--color-bg-white);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
}

.page-title span {
    color: var(--color-primary);
}

/* =============================================================================
   PERIOD BAR
   ============================================================================= */

.period-bar {
    background: var(--color-bg-white);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.period-bar label {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    font-weight: 500;
    margin-bottom: 0;
}

.period-bar input.flatpickr-input {
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--color-text);
    background: #f8fafc;
    width: 120px;
    cursor: pointer;
    box-sizing: border-box;
}

.period-bar input.flatpickr-input:focus {
    border-color: var(--color-primary-light);
    background: var(--color-bg-white);
}

.period-bar .btn-apply {
    padding: 0.5rem 1rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
}

.period-bar .btn-reset {
    padding: 0.5rem 1rem;
    background: var(--color-bg);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    cursor: pointer;
}

/* =============================================================================
   DASHBOARD CONTENT
   ============================================================================= */

.dashboard-content {
    padding: 2rem;
}

/* =============================================================================
   TABLES
   ============================================================================= */

.table-container {
    overflow-x: auto;
    background: var(--color-bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

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

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
}

tr:hover {
    background: #f8fafc;
}

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

.sidebar-toggle {
    display: none;
    background: var(--color-bg-dark);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
}

.sidebar-close-btn {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-slow);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

    .sidebar-close-btn {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .top-header {
        padding: 1rem;
    }

    .dashboard-content {
        padding: 1rem;
    }

    .period-bar {
        padding: 0.75rem 1rem;
    }
}

/* =============================================================================
   UTILITIES
   ============================================================================= */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

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

.text-success {
    color: var(--color-success);
}

.text-error {
    color: var(--color-error);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

/* =============================================================================
   LOADING SPINNER
   ============================================================================= */

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    border-top-color: var(--color-primary);
    animation: spin 1s linear infinite;
}

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

/* =============================================================================
   STAT CARDS (Dashboard)
   ============================================================================= */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

.stat-card .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}

.stat-card .subtitle {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}
