/* ============================================================
   ActorMap – Design System v2
   ============================================================ */

/* --- Variables ------------------------------------------- */
:root {
    --primary:            #6366f1;
    --primary-dark:       #4f46e5;
    --primary-light:      rgba(99, 102, 241, 0.1);
    --primary-gradient:   linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --secondary:          #f59e0b;
    --secondary-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);

    --success: #10b981;
    --warning: #f59e0b;
    --danger:  #ef4444;
    --info:    #3b82f6;

    --bg-gradient: radial-gradient(circle at top right, #f8fafc, #eff6ff);
    --card-bg:     rgba(255, 255, 255, 0.9);
    --glass-bg:    rgba(255, 255, 255, 0.72);

    --text-main:  #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    --border:      rgba(226, 232, 240, 0.9);
    --shadow-soft: 0 4px 24px rgba(31, 38, 135, 0.07);
    --shadow-card: 0 8px 32px rgba(31, 38, 135, 0.10);

    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;

    --sidebar-width: 230px;
    --sidebar-bg:    #1e1b4b;

    /* Legacy aliases for backward compatibility */
    --primary-color:    #6366f1;
    --border-color:     rgba(226, 232, 240, 0.9);
    --text-color:       #1e293b;
    --text-main:        #1e293b;
    --background-color: #f8fafc;
    --warning-color:    #f59e0b;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4 {
    font-family: 'Outfit', 'Inter', sans-serif;
    letter-spacing: -0.02em;
}

/* --- App Shell ------------------------------------------ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar -------------------------------------------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    padding: 1.75rem 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a5b4fc, #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-logo h1 i {
    -webkit-text-fill-color: #818cf8;
    font-size: 1.3rem;
}

.sidebar-logo p {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.75rem 0.75rem 0.35rem;
}

.tab-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 0.65rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    font-family: inherit;
    text-align: left;
    transition: all 0.2s ease;
}

.tab-button i {
    width: 16px;
    text-align: center;
    font-size: 0.875rem;
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity 0.2s;
}

.tab-button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.tab-button:hover i {
    opacity: 1;
}

.tab-button.active {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
}

.tab-button.active i {
    opacity: 1;
}

.sidebar-user {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user .user-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.35);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 0.2rem;
}

.sidebar-user .user-name {
    color: #fff;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.logout-btn {
    color: rgba(255, 255, 255, 0.45);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 500;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.logout-btn:hover {
    color: #fca5a5;
}

/* --- Main Content --------------------------------------- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Container ----------------------------------------- */
.container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 1.75rem 2rem;
    width: 100%;
}

/* --- Global Notice ------------------------------------- */
#globalNotice {
    display: none;
    position: sticky;
    top: 0.5rem;
    z-index: 40;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

/* --- Info Panels (historial + estado) ------------------ */
.info-panels {
    display: grid;
    grid-template-columns: 1fr 1.6fr;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.info-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-soft);
}

.info-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.info-panel-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-panel-title i {
    color: var(--primary);
    font-size: 0.85rem;
}

/* --- Glass Sections ------------------------------------ */
.section {
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s ease;
}

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

/* --- Section Headers ---------------------------------- */
h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

h2 i {
    color: var(--primary);
    font-size: 1rem;
}

h3 {
    font-size: 0.975rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.875rem;
}

/* --- Forms -------------------------------------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

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

label {
    display: block;
    margin-bottom: 0.45rem;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.required-mark {
    color: var(--danger);
    margin-left: 0.15rem;
}

input,
textarea,
select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: rgba(255, 255, 255, 0.75);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-main);
    transition: all 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-light);
}

/* --- Buttons ------------------------------------------ */
button[type="submit"],
.action-btn {
    background: var(--primary-gradient);
    color: #fff;
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: inherit;
    margin-top: 1.25rem;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

button[type="submit"]:hover,
.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.table .action-btn {
    margin-top: 0;
    padding: 0.3rem 0.65rem;
    font-size: 0.75rem;
}

.table .delete-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
    margin-left: 0.25rem;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
    border: 1.5px solid rgba(99, 102, 241, 0.2);
    box-shadow: none;
}

.btn-secondary:hover {
    background: rgba(99, 102, 241, 0.15);
    box-shadow: none;
    transform: none;
}

.btn-warning {
    background: var(--secondary-gradient);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.btn-warning:hover {
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
}

/* --- Tables ------------------------------------------ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 1.25rem;
}

.table th {
    background: rgba(99, 102, 241, 0.05);
    color: var(--text-muted);
    font-weight: 700;
    text-align: left;
    padding: 0.8rem 0.9rem;
    border-bottom: 2px solid var(--border);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
}

.table td {
    padding: 0.8rem 0.9rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    font-size: 0.85rem;
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background: rgba(99, 102, 241, 0.025);
}

/* --- Status Badges ----------------------------------- */
.status {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.65rem;
    border-radius: 2rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.status.sent             { background: #e0f2fe; color: #0369a1; }
.status.pending_response { background: #ffedd5; color: #c2410c; }
.status.overdue          { background: #fee2e2; color: #b91c1c; }
.status.tutela_activated { background: #f3e8ff; color: #7e22ce; }
.status.desacato_activated { background: rgba(30, 41, 59, 0.1); color: #1e293b; }
.status.budget-ok        { background: #dcfce7; color: #166534; }
.status.budget-exceeded  { background: #fee2e2; color: #b91c1c; }

.budget-exceeded-row td      { background: rgba(239, 68, 68, 0.03); }
.budget-exceeded-row:hover td { background: rgba(239, 68, 68, 0.07); }

/* --- Analytics Sub-tabs ------------------------------ */
.analytics-subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.analytics-subtab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    background: rgba(99, 102, 241, 0.05);
    border: 1.5px solid var(--border);
    transition: all 0.2s;
    font-family: inherit;
}

.analytics-subtab:hover {
    color: var(--primary);
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(99, 102, 241, 0.08);
}

.analytics-subtab.active {
    background: var(--primary-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.analytics-panel h3 {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.analytics-panel h4 {
    font-size: 0.875rem;
    color: var(--text-main);
}

/* --- System Status Cards ----------------------------- */
.system-status-card {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #fff;
    font-size: 0.82rem;
}

.system-status-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.system-status-card.ok   .system-status-icon { background: rgba(16,185,129,0.12); color: var(--success); }
.system-status-card.warn .system-status-icon { background: rgba(245,158,11,0.12); color: var(--warning); }
.system-status-card.err  .system-status-icon { background: rgba(239,68,68,0.12);  color: var(--danger); }

/* --- Actor Map ---------------------------------------- */
#actorNetworkContainer {
    background: #fafbfc;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}

/* --- Import code tags --------------------------------- */
#import-section code {
    background: var(--primary-light);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--primary-dark);
}

/* --- Pagination --------------------------------------- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.pagination button {
    margin-top: 0;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    min-width: 34px;
}

/* --- Sub-section dividers ----------------------------- */
.subsection-header {
    margin-top: 0.25rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.85rem;
}

.subsection-header.blue {
    background: rgba(29, 78, 216, 0.07);
    border: 1px solid rgba(29, 78, 216, 0.15);
    color: #1d4ed8;
}

.subsection-header.green {
    background: rgba(20, 108, 67, 0.07);
    border: 1px solid rgba(20, 108, 67, 0.15);
    color: #146c43;
}

.subsection-header.red {
    background: rgba(180, 35, 24, 0.07);
    border: 1px solid rgba(180, 35, 24, 0.15);
    color: #b42318;
}

/* --- Login Page --------------------------------------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 25%, rgba(99, 102, 241, 0.2) 0%, transparent 45%),
        radial-gradient(circle at 85% 75%, rgba(245, 158, 11, 0.12) 0%, transparent 45%),
        var(--bg-gradient);
}

.login-card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 2.75rem;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(31, 38, 135, 0.13);
    width: 100%;
    max-width: 420px;
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.login-icon {
    width: 60px;
    height: 60px;
    background: var(--primary-gradient);
    border-radius: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.32);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.35rem;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.login-field {
    position: relative;
    margin-bottom: 1rem;
}

.login-field label {
    font-size: 0.75rem;
    margin-bottom: 0.4rem;
}

.login-field .field-icon {
    position: absolute;
    left: 0.875rem;
    bottom: 0.72rem;
    color: var(--text-light);
    font-size: 0.82rem;
    pointer-events: none;
}

.login-field input {
    padding-left: 2.5rem;
    font-size: 0.9rem;
}

.login-card button[type="submit"] {
    width: 100%;
    justify-content: center;
    margin-top: 0.75rem;
    padding: 0.85rem;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}

.login-error {
    background: #fee2e2;
    color: #b91c1c;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    text-align: center;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

/* --- Responsive --------------------------------------- */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    }

    .main-content {
        margin-left: 0;
    }

    .info-panels {
        grid-template-columns: 1fr;
    }

    .hamburger {
        display: flex;
    }
}

@media (min-width: 901px) {
    .hamburger { display: none; }
}

.hamburger {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.hamburger:hover {
    color: var(--primary);
}

@media (max-width: 600px) {
    .container { padding: 1rem; }
    .section   { padding: 1.25rem; }
    .form-grid { grid-template-columns: 1fr; }
    .login-card { padding: 2rem 1.5rem; margin: 1rem; }
}
