/* ==========================================================================
   Inv_taller - Estilos Responsive
   Creado por DeepSeek V4 Pro - 2026-07-29
   ========================================================================== */

/* --- Reset & Base -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:    #2c3e50;
    --accent:     #3498db;
    --success:    #27ae60;
    --warning:    #f39c12;
    --danger:     #e74c3c;
    --bg:         #ecf0f1;
    --card:       #ffffff;
    --text:       #2c3e50;
    --text-light: #7f8c8d;
    --border:     #dcdde1;
    --shadow:     0 2px 8px rgba(0,0,0,0.08);
    --radius:     10px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

/* --- Header -------------------------------------------------------------- */
.app-header {
    background: linear-gradient(135deg, #1a2a3a 0%, #2c3e50 100%);
    color: #fff;
    padding: 16px 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-content {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.app-header h1 {
    font-size: clamp(1rem, 3vw, 1.4rem);
    font-weight: 700;
    letter-spacing: -0.3px;
}
.header-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.badge-ai, .badge-date {
    font-size: 0.75rem;
    background: rgba(255,255,255,0.15);
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

/* --- Search Bar ---------------------------------------------------------- */
.search-bar {
    max-width: 1100px;
    margin: 16px auto 8px;
    padding: 0 16px;
    display: flex;
    gap: 8px;
}
.search-bar input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
}
.search-bar input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}
.search-bar button {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    transition: background 0.2s, transform 0.1s;
}
.search-bar button:hover { background: #2980b9; }
.search-bar button:active { transform: scale(0.97); }
.btn-outline {
    background: var(--card) !important;
    color: var(--text) !important;
    border: 2px solid var(--border) !important;
}
.btn-outline:hover { background: #f8f9fa !important; }

/* --- Search Results ------------------------------------------------------ */
.search-results {
    max-width: 1100px;
    margin: 8px auto;
    padding: 0 16px;
}
.search-results-inner {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}
.search-results-inner h3 { margin-bottom: 10px; color: var(--primary); }
.search-results table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.search-results th, .search-results td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.search-results th { background: #f8f9fa; font-weight: 600; position: sticky; top: 0; }
.search-results tr:hover { background: #f0f4f8; }
.search-highlight { background: #ffeaa7; padding: 1px 3px; border-radius: 2px; }

/* --- Cabinet Selector ---------------------------------------------------- */
.cabinet-selector {
    max-width: 1100px;
    margin: 12px auto;
    padding: 0 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.cabinet-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 14px;
    border: 3px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 60px;
    position: relative;
}
.cabinet-btn:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.cabinet-btn.active {
    border-color: var(--accent);
    background: #eaf4fd;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.2);
}
.cabinet-btn.locked-state { border-color: var(--danger); background: #fdecea; }
.cabinet-letter { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.cabinet-size  { font-size: 0.7rem; color: var(--text-light); }
.lock-icon     { position: absolute; top: 4px; right: 6px; font-size: 0.8rem; }

/* --- Cabinet Info -------------------------------------------------------- */
.cabinet-info {
    max-width: 1100px;
    margin: 8px auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.cabinet-info-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cabinet-info-left h2 { font-size: 1.2rem; }
.cabinet-desc { font-size: 0.85rem; color: var(--text-light); }
.cabinet-stats { font-size: 0.85rem; background: #e8f5e9; color: #2e7d32; padding: 4px 10px; border-radius: 20px; }
.btn-lock {
    font-size: 1.5rem;
    background: none;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 14px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-lock:hover { border-color: var(--danger); background: #fdecea; }
.btn-lock.locked { border-color: var(--danger); background: #fdecea; }

/* --- Grid ----------------------------------------------------------------- */
.grid-container {
    max-width: 1100px;
    margin: 8px auto 20px;
    padding: 0 16px;
    overflow-x: auto;
}
.grid-placeholder {
    text-align: center;
    color: var(--text-light);
    padding: 60px 20px;
    font-size: 1.1rem;
}
.gaveta-grid {
    display: grid;
    gap: 3px;
    background: var(--border);
    border-radius: 6px;
    padding: 3px;
    margin: 0 auto;
}
.gaveta-cell {
    aspect-ratio: 1;
    min-width: 38px;
    min-height: 38px;
    background: #f9f9f9;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 600;
    color: #999;
    transition: all 0.15s;
    position: relative;
    user-select: none;
    border: 2px solid transparent;
}
.gaveta-cell:hover {
    transform: scale(1.05);
    z-index: 2;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border-color: var(--accent);
}
.gaveta-cell.filled {
    background: #d5f5e3;
    color: #1e8449;
    border-color: #82e0aa;
}
.gaveta-cell.filled:hover { background: #abebc6; }
.gaveta-cell.locked-cell {
    background: #fadbd8;
    color: #c0392b;
    cursor: not-allowed;
    border-color: #f1948a;
}
.gaveta-cell.locked-cell:hover { transform: none; border-color: #e74c3c; }
.gaveta-cell .cell-pos { font-size: 0.6rem; opacity: 0.7; }
.gaveta-cell .cell-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--success);
    position: absolute;
    top: 4px; right: 4px;
}
.gaveta-cell.locked-cell .cell-dot { background: var(--danger); }

/* Row & Column labels */
.grid-labels-top {
    display: grid;
    gap: 3px;
    margin-bottom: 2px;
    padding: 0 3px;
}
.grid-label-col {
    text-align: center;
    font-size: 0.6rem;
    color: var(--text-light);
    font-weight: 700;
}

/* --- Legend -------------------------------------------------------------- */
.legend {
    max-width: 1100px;
    margin: 0 auto 20px;
    padding: 0 16px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-light);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot {
    width: 14px; height: 14px;
    border-radius: 4px;
    border: 2px solid var(--border);
}
.dot-empty  { background: #f9f9f9; }
.dot-filled { background: #d5f5e3; border-color: #82e0aa; }
.dot-locked { background: #fadbd8; border-color: #f1948a; }

/* --- Modal --------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.25s;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}
.modal-close:hover { background: #f0f0f0; }

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-primary, .btn-outline, .btn-add-item, .btn-danger {
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #2980b9; }
.btn-outline { background: #fff; color: var(--text); border: 2px solid var(--border); }
.btn-outline:hover { background: #f8f9fa; }
.btn-add-item {
    background: #e8f5e9;
    color: #2e7d32;
    width: 100%;
    margin-top: 12px;
    border: 2px dashed #a5d6a7;
    font-size: 0.95rem;
}
.btn-add-item:hover { background: #c8e6c9; }
.btn-danger { background: #fff; color: var(--danger); border: 2px solid #f1948a; }
.btn-danger:hover { background: #fdecea; }

/* Item rows in modal */
.item-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    animation: fadeIn 0.2s;
}
.item-row input[type="number"] {
    width: 65px;
    padding: 8px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    text-align: center;
}
.item-row input[type="text"] {
    flex: 1;
    padding: 8px 10px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
}
.item-row input:focus {
    outline: none;
    border-color: var(--accent);
}
.item-row .btn-remove {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}
.item-row .btn-remove:hover { background: #fdecea; }

/* --- Toast --------------------------------------------------------------- */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    animation: toastIn 0.3s, toastOut 0.3s 2.5s forwards;
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
}
.toast.success { background: #27ae60; color: #fff; }
.toast.error   { background: #e74c3c; color: #fff; }
.toast.info    { background: #2c3e50; color: #fff; }

@keyframes toastIn  { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(-50%) translateY(-10px); } }

/* --- Error box ----------------------------------------------------------- */
.error-box {
    background: #fdecea;
    border: 2px solid #e74c3c;
    border-radius: var(--radius);
    padding: 16px;
    color: #c0392b;
}
.error-box a { color: #c0392b; font-weight: 700; }

/* --- Footer -------------------------------------------------------------- */
.app-footer {
    margin-top: auto;
    text-align: center;
    padding: 16px;
    color: var(--text-light);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 768px) {
    .app-header h1 { font-size: 0.95rem; }
    .cabinet-btn { padding: 8px 10px; min-width: 48px; }
    .cabinet-letter { font-size: 1.1rem; }
    .cabinet-size { font-size: 0.6rem; }
    .gaveta-cell { min-width: 30px; min-height: 30px; font-size: 0.55rem; }
    .gaveta-cell .cell-pos { font-size: 0.5rem; }
    .modal-content { max-width: 95vw; }
    .item-row { flex-wrap: wrap; }
    .item-row input[type="number"] { width: 55px; }
    .search-bar input { font-size: 0.9rem; padding: 8px 12px; }
    .search-bar button { padding: 8px 14px; font-size: 0.85rem; }
}

@media (max-width: 400px) {
    .gaveta-cell { min-width: 26px; min-height: 26px; font-size: 0.5rem; }
    .gaveta-grid { gap: 2px; padding: 2px; }
    .cabinet-btn { padding: 6px 8px; min-width: 40px; }
    .cabinet-info-left h2 { font-size: 1rem; }
}
