/* DataParser App - Estilos base */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    width: 220px;
    background: var(--gray-900);
    color: white;
    padding: 1.5rem 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar h2 {
    padding: 0 1.25rem;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--gray-200);
}

.sidebar nav a {
    display: block;
    padding: 0.6rem 1.25rem;
    color: var(--gray-300);
    font-size: 0.9rem;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: rgba(255,255,255,0.1);
    color: white;
    text-decoration: none;
}

.sidebar .user-info {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
}

/* Login */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--gray-100);
}

.login-box {
    background: white;
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 380px;
}

.login-box h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Formularios */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
    color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
}

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

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

/* Botones */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    line-height: 1.5;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-block { display: block; width: 100%; }

/* Tablas */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

th, td {
    padding: 0.65rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.875rem;
}

th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
}

tr:last-child td { border-bottom: none; }
tr:hover { background: var(--gray-50); }

/* Badges de estado */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-open { background: #dbeafe; color: #1e40af; }
.badge-complete { background: #d1fae5; color: #065f46; }
.badge-processing { background: #fef3c7; color: #92400e; }
.badge-done { background: #e0e7ff; color: #3730a3; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-in_progress { background: #dbeafe; color: #1e40af; }
.badge-ready { background: #d1fae5; color: #065f46; }
.badge-delivered { background: #e0e7ff; color: #3730a3; }

/* Mensajes flash */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* Cards */
.card {
    background: white;
    border-radius: 6px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 1.5rem;
}

.card h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--gray-700);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: white;
    padding: 1rem;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

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

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.2rem;
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.4rem;
}

/* Formularios inline */
.inline-form {
    display: inline;
}

.form-row {
    display: flex;
    gap: 0.75rem;
    align-items: end;
}

.form-row .form-group {
    margin-bottom: 0;
}

/* Métricas lista */
.metrics-list {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
}

.metrics-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.85rem;
}

.metrics-list li span:last-child {
    font-weight: 600;
    color: var(--gray-700);
}

/* Modal básico */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.modal h3 {
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
