/* ============================================================
   LabelSync – app.css  (tema Light Clean · Beat House Miami)
   Acento: #e8178a (magenta Beat House)
   ============================================================ */

/* ------------------------------------------------------------
   VARIABLES
------------------------------------------------------------ */
:root {
    --accent:          #e8178a;
    --accent-hover:    #c8106f;
    --accent-soft:     rgba(232, 23, 138, 0.08);
    --accent-border:   rgba(232, 23, 138, 0.25);

    --bg:              #f5f5f3;
    --bg-surface:      #ffffff;
    --bg-card:         #ffffff;
    --bg-hover:        #f9f9f7;
    --bg-input:        #fafaf8;

    --border:          #e8e8e4;
    --border-mid:      #d8d8d2;

    --text:            #1a1a1a;
    --text-muted:      #888880;
    --text-hint:       #c0c0b8;

    --success:         #2e7d32;
    --success-soft:    #e8f5e9;
    --warning:         #e65100;
    --warning-soft:    #fff3e0;
    --danger:          #c62828;
    --danger-soft:     #fdecea;
    --info:            #1565c0;
    --info-soft:       #e3f2fd;

    --sidebar-width:   220px;
    --header-height:   52px;
    --radius:          7px;
    --radius-lg:       10px;
    --radius-xl:       14px;
    --transition:      0.15s ease;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ------------------------------------------------------------
   LOGIN
------------------------------------------------------------ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #fff;
}

#login-wrapper {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

#login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo img {
    max-width: 220px;
    height: auto;
    margin: 0 auto 10px;
    display: block;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 6px;
    letter-spacing: 0.3px;
}

/* ------------------------------------------------------------
   FORMULARIOS
------------------------------------------------------------ */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 9px 12px;
    font-size: 13px;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888880' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    padding-right: 32px;
}

.error-msg {
    background: var(--danger-soft);
    border: 1px solid #f5c6c2;
    color: var(--danger);
    border-radius: var(--radius);
    padding: 9px 13px;
    font-size: 13px;
    margin-bottom: 14px;
}

/* ------------------------------------------------------------
   BOTONES
------------------------------------------------------------ */
.btn-primary {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 11px 22px;
    font-size: 14px;
    font-weight: 600;
    transition: background var(--transition), transform var(--transition);
    letter-spacing: 0.1px;
}
.btn-primary:hover  { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 500;
    transition: background var(--transition), border-color var(--transition);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-mid); }

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid #f5c6c2;
    border-radius: var(--radius);
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 500;
    transition: background var(--transition);
}
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 7px;
    border-radius: var(--radius);
    font-size: 16px;
    transition: color var(--transition), background var(--transition);
    position: relative;
}
.icon-btn:hover { color: var(--text); background: var(--bg-hover); }

/* ------------------------------------------------------------
   LAYOUT PRINCIPAL
------------------------------------------------------------ */
.app-loaded { overflow: hidden; }

#app-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
}

/* ------------------------------------------------------------
   SIDEBAR
------------------------------------------------------------ */
#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    flex-shrink: 0;
    transition: transform var(--transition);
    overflow-y: auto;
}

.sidebar-logo {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.sidebar-logo img {
    width: 120px;
    height: auto;
}

.sidebar-logo-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.3px;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 1px;
    cursor: pointer;
}

.nav-item:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.nav-item.active {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 600;
}

.nav-item svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.6;
}
.nav-item.active svg { opacity: 1; }

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-hint);
    padding: 14px 10px 5px;
}

/* Usuario pie del sidebar */
.sidebar-user {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 9px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.user-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--accent-border);
}

.user-info { flex: 1; min-width: 0; }

.user-name {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
}

#btn-logout {
    color: var(--text-hint);
    font-size: 13px;
    padding: 4px;
    transition: color var(--transition);
    background: none;
    border: none;
}
#btn-logout:hover { color: var(--danger); }

/* ------------------------------------------------------------
   ÁREA PRINCIPAL
------------------------------------------------------------ */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

#top-header {
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    flex-shrink: 0;
}

#btn-toggle-sidebar {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    padding: 6px;
    display: none;
    cursor: pointer;
}

#page-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

#header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 15px;
    height: 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

#view-container {
    flex: 1;
    overflow-y: auto;
    padding: 22px 24px;
}

/* ------------------------------------------------------------
   CARDS
------------------------------------------------------------ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* ------------------------------------------------------------
   TABLA
------------------------------------------------------------ */
.table-wrapper { overflow-x: auto; }

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

thead th {
    text-align: left;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid #f5f5f2;
    font-size: 13px;
    color: var(--text);
}

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

/* ------------------------------------------------------------
   BADGES DE ESTADO
------------------------------------------------------------ */
.badge-estado {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-pendiente     { background: #f5f5f2;              color: var(--text-muted); }
.badge-en_proceso    { background: var(--info-soft);      color: var(--info); }
.badge-completada    { background: var(--success-soft);   color: var(--success); }
.badge-retrasada     { background: var(--danger-soft);    color: var(--danger); }
.badge-en_riesgo     { background: var(--warning-soft);   color: var(--warning); }
.badge-planificacion { background: var(--accent-soft);    color: var(--accent); }
.badge-finalizado    { background: var(--success-soft);   color: var(--success); }

.badge-prioridad-alta  { background: var(--danger-soft);  color: var(--danger); }
.badge-prioridad-media { background: var(--warning-soft); color: var(--warning); }
.badge-prioridad-baja  { background: var(--success-soft); color: var(--success); }

/* ------------------------------------------------------------
   FILTROS / PILLS
------------------------------------------------------------ */
.filter-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-pill {
    padding: 5px 13px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.filter-pill:hover { border-color: var(--accent); color: var(--accent); }

.filter-pill.active {
    background: var(--accent-soft);
    border-color: var(--accent-border);
    color: var(--accent);
}

/* ------------------------------------------------------------
   PANEL DE NOTIFICACIONES
------------------------------------------------------------ */
#notifications-panel {
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: 320px;
    max-height: calc(100vh - var(--header-height));
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    overflow-y: auto;
    z-index: 200;
    box-shadow: -4px 0 16px rgba(0,0,0,0.06);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-surface);
}

.panel-header h3 { font-size: 13px; font-weight: 600; }

.notif-item {
    padding: 12px 18px;
    border-bottom: 1px solid #f5f5f2;
    transition: background var(--transition);
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item.no-leida { border-left: 3px solid var(--accent); }

.notif-mensaje { font-size: 13px; color: var(--text); margin-bottom: 3px; }
.notif-fecha   { font-size: 11px; color: var(--text-hint); }

/* ------------------------------------------------------------
   OVERLAY
------------------------------------------------------------ */
#overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.25);
    z-index: 150;
}

/* ------------------------------------------------------------
   MODALES
------------------------------------------------------------ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-box {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 26px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.modal-title { font-size: 16px; font-weight: 600; color: var(--text); }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    padding: 4px;
    line-height: 1;
    border-radius: var(--radius);
    transition: background var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }

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

/* ------------------------------------------------------------
   MÉTRICAS (cards de números)
------------------------------------------------------------ */
.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
}

.metric-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.metric-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.metric-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ------------------------------------------------------------
   PROGRESS BAR
------------------------------------------------------------ */
.progress-bar {
    height: 4px;
    background: #f0f0ec;
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.progress-fill.danger  { background: var(--danger); }
.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: #e67e22; }

/* ------------------------------------------------------------
   CHECKBOX
------------------------------------------------------------ */
input[type="checkbox"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

/* ------------------------------------------------------------
   LOADING Y UTILIDADES
------------------------------------------------------------ */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    font-size: 13px;
}

.hidden { display: none !important; }

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

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }

.flex         { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap     { display: flex; align-items: center; gap: 10px; }
.flex-wrap    { flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }

/* ------------------------------------------------------------
   RESPONSIVE – MÓVIL
------------------------------------------------------------ */
@media (max-width: 768px) {
    #btn-toggle-sidebar { display: block; }

    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 250;
        transform: translateX(-100%);
    }

    #sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 16px rgba(0,0,0,0.1);
    }

    #view-container { padding: 14px 16px; }

    .grid-2,
    .grid-3,
    .grid-4 { grid-template-columns: 1fr; }

    .modal-box { padding: 20px; }

    #notifications-panel { width: 100%; }
}
