/* ===== Variables CSS y Temas ===== */

/* Azul - Profesional */
:root, [data-theme="blue"] {
    --bg-main: #0b1020;
    --card-bg: #121c2f;
    --accent-primary: #4f46e5;
    --accent-secondary: #93c5fd;
    --accent-tertiary: rgba(99, 102, 241, 0.16);
    --text-main: #f8fafc;
    --text-dim: #9aa7c0;
    --danger: #ef4444;
    --success: #22c55e;
    --border-subtle: rgba(99, 102, 241, 0.08);
    --input-bg: #0f172a;
    --input-border: #334155;

    --shadow-base: 0 25px 50px -12px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(79, 70, 229, 0.05);
}

/* Verde - Natural */
[data-theme="green"] {
    --bg-main: #07170d;
    --card-bg: #102218;
    --accent-primary: #22c55e;
    --accent-secondary: #86efac;
    --accent-tertiary: rgba(74, 222, 128, 0.16);
    --text-main: #f0fff4;
    --text-dim: #8fb39d;
    --danger: #ef4444;
    --success: #22c55e;
    --border-subtle: rgba(74, 222, 128, 0.08);
    --input-bg: #0a1b10;
    --input-border: #2f5d43;

    --shadow-base: 0 25px 50px -12px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(74, 222, 128, 0.04);
}

/* Naranja - Cálido */
[data-theme="orange"] {
    --bg-main: #1b1108;
    --card-bg: #28170d;
    --accent-primary: #ea580c;
    --accent-secondary: #fdba74;
    --accent-tertiary: rgba(251, 146, 60, 0.16);
    --text-main: #fff7ed;
    --text-dim: #ccb39e;
    --danger: #fb7185;
    --success: #22c55e;
    --border-subtle: rgba(251, 146, 60, 0.08);
    --input-bg: #1a1209;
    --input-border: #7c3f16;

    --shadow-base: 0 25px 50px -12px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(251, 146, 60, 0.05);
}

/* Púrpura - Creativo */
[data-theme="purple"] {
    --bg-main: #140c1f;
    --card-bg: #201531;
    --accent-primary: #7c3aed;
    --accent-secondary: #c4b5fd;
    --accent-tertiary: rgba(124, 58, 237, 0.16);
    --text-main: #faf5ff;
    --text-dim: #b8a9da;
    --danger: #f87171;
    --success: #22c55e;
    --border-subtle: rgba(124, 58, 237, 0.08);
    --input-bg: #171024;
    --input-border: #5b3ca7;

    --shadow-base: 0 25px 50px -12px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(124, 58, 237, 0.05);
}

/* Rojo - Energético */
[data-theme="red"] {
    --bg-main: #1a0d0d;
    --card-bg: #281414;
    --accent-primary: #dc2626;
    --accent-secondary: #fca5a5;
    --accent-tertiary: rgba(220, 38, 38, 0.16);
    --text-main: #fff5f5;
    --text-dim: #d7a9a9;
    --danger: #f87171;
    --success: #22c55e;
    --border-subtle: rgba(220, 38, 38, 0.08);
    --input-bg: #210d0d;
    --input-border: #7f1d1d;

    --shadow-base: 0 25px 50px -12px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(220, 38, 38, 0.05);
}

/* Turquesa - Fresco */
[data-theme="teal"] {
    --bg-main: #071718;
    --card-bg: #102627;
    --accent-primary: #0d9488;
    --accent-secondary: #5eead4;
    --accent-tertiary: rgba(20, 184, 166, 0.16);
    --text-main: #f0fffe;
    --text-dim: #9ac5bf;
    --danger: #f87171;
    --success: #34d399;
    --border-subtle: rgba(20, 184, 166, 0.08);
    --input-bg: #0a1f1f;
    --input-border: #245e5b;

    --shadow-base: 0 25px 50px -12px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(20, 184, 166, 0.05);
}

/* ===== Temas de Producción con Paletas Completas ===== */

/* Azul - Profesional (Azul índigo con variantes) */
[data-production-theme="blue"] {
    --accent-primary: #4f46e5;      /* Indigo 600 */
    --accent-secondary: #93c5fd;     /* Blue 300 */
    --accent-tertiary: rgba(99, 102, 241, 0.16);
    --card-bg: #121c2f;
    --input-bg: #0f172a;
    --input-border: #334155;
    --success: #22c55e;
    --danger: #ef4444;
}

/* Verde - Natural (Verde con variantes) */
[data-production-theme="green"] {
    --accent-primary: #22c55e;      /* Green 500 */
    --accent-secondary: #86efac;     /* Green 300 */
    --accent-tertiary: rgba(74, 222, 128, 0.16);
    --card-bg: #102218;
    --input-bg: #0a1b10;
    --input-border: #2f5d43;
    --success: #86efac;
    --danger: #f87171;
}

/* Naranja - Cálido (Naranja con variantes) */
[data-production-theme="orange"] {
    --accent-primary: #ea580c;      /* Amber 600 */
    --accent-secondary: #fdba74;    /* Orange 300 */
    --accent-tertiary: rgba(251, 146, 60, 0.16);
    --card-bg: #28170d;
    --input-bg: #1a1209;
    --input-border: #7c3f16;
    --success: #4ade80;
    --danger: #f87171;
}

/* Púrpura - Creativo (Violeta con variantes) */
[data-production-theme="purple"] {
    --accent-primary: #7c3aed;      /* Violet 600 */
    --accent-secondary: #c4b5fd;     /* Violet 300 */
    --accent-tertiary: rgba(124, 58, 237, 0.16);
    --card-bg: #201531;
    --input-bg: #171024;
    --input-border: #5b3ca7;
    --success: #4ade80;
    --danger: #f87171;
}

/* Rojo - Energético (Rojo con variantes) */
[data-production-theme="red"] {
    --accent-primary: #dc2626;      /* Red 600 */
    --accent-secondary: #fca5a5;    /* Red 300 */
    --accent-tertiary: rgba(220, 38, 38, 0.16);
    --card-bg: #281414;
    --input-bg: #210d0d;
    --input-border: #7f1d1d;
    --success: #4ade80;
    --danger: #f87171;
}

/* Turquesa - Fresco (Teal con variantes) */
[data-production-theme="teal"] {
    --accent-primary: #0d9488;      /* Teal 600 */
    --accent-secondary: #5eead4;    /* Teal 300 */
    --accent-tertiary: rgba(20, 184, 166, 0.16);
    --card-bg: #102627;
    --input-bg: #0a1f1f;
    --input-border: #245e5b;
    --success: #34d399;
    --danger: #f87171;
}

/* ===== Formatos (Layouts) ===== */
/* Por defecto: Compacto */
:root, [data-layout="compact"] {
    --ui-padding: 24px;
    --btn-height: 48px;
    --font-size-base: 14px;
    --font-size-title: 26px;
    --border-radius: 20px;
}

/* Expandido (Tablets industriales - Grandes objetivos táctiles) */
[data-layout="expanded"] {
    --ui-padding: 32px;
    --btn-height: 64px; /* Shield rule: 64px min touch target */
    --font-size-base: 18px;
    --font-size-title: 36px;
    --border-radius: 28px;
}

/* ===== Reset & Base ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    width: 100%;
    max-width: 600px;
    background: var(--card-bg);
    padding: var(--ui-padding);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-base);
    border: 1px solid var(--border-subtle);
    margin: 0 auto;
    transition: all 0.3s ease;
}

header {
    text-align: center;
    margin-bottom: 24px;
}

h1 {
    font-size: var(--font-size-title);
    font-weight: 900;
    letter-spacing: -1px;
    color: var(--text-main);
    text-transform: uppercase;
}

.subtitle {
    font-size: calc(var(--font-size-base) * 0.85);
    color: var(--accent-secondary);
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    display: block;
    margin-top: 4px;
}

/* ===== Navegación ===== */
.tab-nav {
    display: flex;
    background: var(--input-bg);
    padding: 6px;
    border-radius: calc(var(--border-radius) / 2);
    margin-bottom: 24px;
    border: 1px solid var(--border-subtle);
    gap: 4px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 0;
    min-height: var(--btn-height);
    border-radius: calc(var(--border-radius) / 3);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    font-size: calc(var(--font-size-base) * 0.85);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Botones y Controles ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--btn-height);
    padding: 0 20px;
    border: none;
    border-radius: calc(var(--border-radius) / 3);
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: var(--font-size-base);
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    margin-bottom: 12px;
}

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

.btn-secondary {
    background-color: transparent;
    color: var(--text-main);
    border: 2px solid var(--input-border);
}

.btn:active {
    transform: scale(0.98);
}

/* Layout utilitario para inputs */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-size: calc(var(--font-size-base) * 0.85);
    font-weight: 700;
    color: var(--text-dim);
    margin-bottom: 8px;
    text-transform: uppercase;
}

input, select {
    width: 100%;
    min-height: var(--btn-height);
    background: var(--input-bg);
    border: 2px solid var(--input-border);
    border-radius: calc(var(--border-radius) / 3);
    padding: 0 16px;
    color: var(--text-main);
    font-size: var(--font-size-base);
    font-weight: 700;
    outline: none;
    font-family: 'Inter', sans-serif;
}

input:focus, select:focus {
    border-color: var(--accent-primary);
}

/* ===== Modales ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: var(--ui-padding);
}

.modal-content {
    background: var(--card-bg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: var(--ui-padding);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-base);
    border: 1px solid var(--border-subtle);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Tarjetas de Lista */
.list-item {
    background: var(--input-bg);
    border: 1px solid var(--border-subtle);
    padding: 16px;
    border-radius: calc(var(--border-radius) / 2);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.list-item:hover {
    border-color: var(--accent-primary);
}

/* ===== Bloques de Modelo (Plantillas) ===== */
.model-block {
    background: var(--input-bg);
    border: 1px solid var(--border-subtle);
    border-radius: calc(var(--border-radius) / 3);
    padding: 12px;
    margin-bottom: 12px;
}

.model-header {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.model-header input {
    min-height: 40px;
    font-size: 13px;
}

.model-subgrid {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.subfield {
    flex: 1;
}

.subfield input {
    width: 100%;
    min-height: 36px;
    font-size: 12px;
    padding: 8px;
}

.measures-list {
    padding-left: 8px;
    border-left: 2px solid var(--accent-primary);
    margin: 8px 0;
}

.measure-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

.measure-row input {
    min-height: 36px;
    font-size: 13px;
    flex: 1;
}

.measure-bullet {
    font-size: 14px;
    flex-shrink: 0;
}

.btn-add-measure {
    background: transparent;
    border: 1px dashed var(--accent-primary);
    color: var(--accent-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    font-family: 'Inter', sans-serif;
    transition: background 0.2s;
}

.btn-add-measure:hover {
    background: var(--accent-tertiary);
}

/* ===== Picklist con búsqueda (Producción) ===== */
.search-picklist {
    position: relative;
    margin-bottom: 16px;
}

.search-picklist input[type="text"] {
    width: 100%;
    min-height: var(--btn-height);
    padding-left: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238fb39d' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 14px center;
}

.picklist-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-subtle);
    border-radius: calc(var(--border-radius) / 3);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    display: none;
}

.picklist-dropdown.visible {
    display: block;
}

.picklist-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-subtle);
    min-height: 48px;
}

.picklist-option:last-child {
    border-bottom: none;
}

.picklist-option:hover {
    background: var(--accent-tertiary);
}

.picklist-option .opt-name {
    font-weight: 700;
    font-size: 14px;
}

.picklist-option .opt-measure {
    font-size: 12px;
    color: var(--text-dim);
}

/* Entradas de producción del día */
.prod-entry-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-subtle);
    border-radius: calc(var(--border-radius) / 3);
    padding: 12px;
    margin-bottom: 8px;
    animation: fadeIn 0.2s ease;
}

.prod-entry-card .entry-info {
    width: 100%;
}

.prod-entry-card .entry-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.prod-entry-card .entry-name {
    font-weight: 800;
    font-size: 14px;
    line-height: 1.15;
}

.prod-entry-card .entry-measure {
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
    flex-shrink: 0;
}

.prod-entry-card .entry-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-dim);
}

.prod-entry-card .entry-meta span {
    white-space: nowrap;
}

.prod-entry-card .entry-controls {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 8px;
    align-items: end;
}

.prod-entry-card .entry-field {
    min-width: 0;
}

.prod-entry-card .entry-field label {
    display: block;
    text-align: center;
    margin-bottom: 4px;
    font-size: 10px;
    line-height: 1;
}

.prod-entry-card input[type="number"] {
    width: 100%;
    min-height: 40px;
    text-align: center;
    font-size: 16px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--danger);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 520px) {
    .prod-entry-card {
        padding: 10px;
        gap: 10px;
    }

    .prod-entry-card .entry-head {
        align-items: center;
    }

    .prod-entry-card .entry-name {
        font-size: 13px;
    }

    .prod-entry-card .entry-meta {
        display: none;
    }

    .prod-entry-card .entry-controls {
        grid-template-columns: repeat(3, minmax(0, 1fr)) 34px;
        gap: 6px;
    }

    .prod-entry-card input[type="number"] {
        min-height: 36px;
        font-size: 14px;
    }

    .prod-entry-card .btn-icon.remove-entry {
        min-width: 34px;
        min-height: 34px;
        padding: 0;
        font-size: 15px;
        align-self: center;
    }
}
