/* ALPE Esquemas - App Styles
   Based on Marketplace Design System */

/* CSS Variables */
:root {
    --navy: #003366;
    --gold: #fdb714;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
}

/* Base Typography */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--gray-800);
    line-height: 1.5;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--gray-200);
}

.card-hover {
    transition: box-shadow 0.3s ease;
}

.card-hover:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    text-decoration: none;
}

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

.btn-primary:hover {
    background-color: #f59e0b;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: white;
    color: var(--navy);
    border: 2px solid var(--navy);
}

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

.btn-tertiary {
    background-color: var(--gray-200);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-tertiary:hover {
    background-color: var(--gray-300);
}

/* Form Elements */
.input-field {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    background: white;
}

.input-field:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1);
}

select.input-field {
    appearance: none;
    background: white url('data:image/svg+xml;utf8,<svg fill="%23374151" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M7 7l3 3 3-3" stroke="%23374151" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" fill="none"/></svg>') no-repeat right 12px center;
    background-size: 20px;
    padding-right: 44px;
    cursor: pointer;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background-color: #dcfce7;
    color: #166534;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background-color: var(--primary-50, #e6f0ff);
    color: var(--navy);
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background-color: var(--gray-50);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-200);
}

.data-table td {
    padding: 12px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--gray-100);
}

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

/* Stat Cards */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--gray-200);
}

.stat-card-title {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

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

/* iOS Safe Area Support */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}

/* Mobile Navigation */
@media (max-width: 768px) {
    body {
        -webkit-tap-highlight-color: transparent;
        -webkit-text-size-adjust: 100%;
    }

    /* Mobile Form Optimizations - 16px font to prevent iOS zoom */
    select,
    input[type="number"],
    input[type="text"],
    input[type="date"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    textarea {
        font-size: 16px !important;
        padding: 14px 16px;
        border-radius: 10px;
        -webkit-appearance: none;
        appearance: none;
    }

    /* iOS Select styling */
    select {
        background-position: right 14px center;
        padding-right: 48px;
    }

    /* Touch-friendly buttons */
    .btn,
    button,
    [role="button"] {
        min-height: 44px;
        padding: 14px 20px;
        font-size: 1rem;
        border-radius: 10px;
    }

    /* Full-width buttons on mobile */
    .flex.justify-end.space-x-4 {
        flex-direction: column;
        gap: 0.75rem;
    }

    .flex.justify-end.space-x-4 > button,
    .flex.justify-end.space-x-4 > a {
        width: 100%;
        justify-content: center;
    }

    .card {
        border-radius: 10px;
        margin: 0.5rem;
    }

    /* Sector block touch targets */
    .sector-block {
        padding: 1rem;
    }

    .sector-block .grid {
        gap: 1rem;
    }

    /* Table scroll on mobile */
    .table-container,
    .overflow-x-auto {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    .data-table,
    table.min-w-full {
        min-width: 600px;
    }

    .data-table th,
    .data-table td,
    table th,
    table td {
        padding: 10px 8px;
        font-size: 0.8125rem;
        white-space: nowrap;
    }

    .data-table th,
    table th {
        font-size: 0.6875rem;
    }

    /* Mobile stat cards - stack on small screens */
    .grid.grid-cols-2.md\\:grid-cols-4,
    .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .grid.grid-cols-1.md\\:grid-cols-3 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    /* Smaller text in stat cards on mobile */
    .text-2xl {
        font-size: 1.25rem;
    }

    .text-xl {
        font-size: 1.125rem;
    }

    /* Reduce padding on mobile cards */
    .p-6 {
        padding: 1rem;
    }

    .p-5 {
        padding: 1rem;
    }

    /* Fix header overflow on mobile */
    .flex.justify-between.items-center {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    /* Mobile navigation slide-in */
    #mobile-nav-content {
        transform: translateX(-100%);
        transition: transform 0.3s ease-out;
    }
}

/* Extra small screens */
@media (max-width: 375px) {
    .grid.grid-cols-2 {
        grid-template-columns: 1fr;
    }

    .text-2xl {
        font-size: 1.125rem;
    }

    .text-lg {
        font-size: 1rem;
    }

    h1.text-2xl, h1.text-3xl {
        font-size: 1.25rem;
    }
}

/* Touch-friendly checkboxes and radios */
input[type="checkbox"],
input[type="radio"] {
    min-width: 20px;
    min-height: 20px;
}

/* Mobile Menu Animation */
#mobile-nav.active {
    display: block;
}

#mobile-nav.active #mobile-nav-content {
    transform: translateX(0);
}

/* Form Section Headers */
.section-header {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--gold);
}

/* Results highlight */
.result-highlight {
    background: linear-gradient(135deg, var(--navy) 0%, #004080 100%);
    color: white;
    border-radius: 12px;
    padding: 1.5rem;
}

.result-highlight .label {
    color: var(--gold);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.result-highlight .value {
    font-size: 1.75rem;
    font-weight: 700;
}

/* Chart container */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

@media (max-width: 768px) {
    .chart-container {
        height: 250px;
    }
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Sector blocks */
.sector-block {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.sector-block:hover {
    border-color: var(--gray-300);
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--gray-300);
    }

    nav, footer {
        display: none;
    }
}
