/* ── Google Fonts ────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..700;1,300..700&family=Ubuntu+Sans:ital,wght@0,100..800;1,100..800&family=Ubuntu+Sans+Mono:ital,wght@0,300..700;1,300..700&display=swap');

/* ── Design tokens ───────────────────────────────────────────────────────────── */
:root {
    --color-bg:           #FFFFFF;
    --color-surface:      #F5F7FA;
    --color-border:       #E2E6EA;
    --color-primary:      #0047AB;
    --color-primary-h:    #003A8C;
    --color-text:         #111827;
    --color-text-muted:   #6B7280;
    --color-text-inv:     #FFFFFF;
    --color-error:        #DC2626;
    --color-warning:      #D97706;
    --color-success:      #16A34A;

    --sidebar-w:          240px;
    --radius:             4px;

    --font-body:          'Open Sans',      system-ui, sans-serif;
    --font-heading:       'Ubuntu Sans',    system-ui, sans-serif;
    --font-mono:          'Ubuntu Sans Mono', monospace;
}

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

html, body { height: 100%; }

body {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    background: var(--color-bg);
    color: var(--color-text);
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    color: #000000;
}

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

/* ── Layout ──────────────────────────────────────────────────────────────────── */
body:not(.page--login) {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.main-content {
    padding: 2rem;
    overflow-y: auto;
    background: var(--color-bg);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar__brand {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.sidebar__logo {
    display: block;
    max-width: 140px;
    height: auto;
    margin-bottom: .75rem;
}

.sidebar__tagline {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 500;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.sidebar__nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    padding: 1rem .75rem;
}

.sidebar__link {
    display: block;
    padding: .5rem .75rem;
    border-radius: var(--radius);
    color: #4B5563;
    font-family: var(--font-body);
    font-size: .875rem;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
    text-decoration: none;
}

.sidebar__link:hover {
    background: #E8ECF0;
    color: var(--color-text);
    text-decoration: none;
}

.sidebar__link--active {
    border-left-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(0, 71, 171, .06);
    font-weight: 600;
}

.sidebar__link--active:hover {
    background: rgba(0, 71, 171, .10);
    color: var(--color-primary);
}

.sidebar__logout {
    padding: .75rem;
    border-top: 1px solid var(--color-border);
}

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

.page-header__title {
    font-family: var(--font-heading);
    font-size: 1.375rem;
    font-weight: 700;
    color: #000000;
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background .15s, opacity .15s;
    text-decoration: none;
}

.btn--primary             { background: var(--color-primary); color: #FFFFFF; }
.btn--primary:hover       { background: var(--color-primary-h); color: #FFFFFF; text-decoration: none; }
.btn--ghost               { background: transparent; color: var(--color-text-muted); border: 1px solid var(--color-border); }
.btn--ghost:hover         { background: var(--color-surface); color: var(--color-text); text-decoration: none; }
.btn--sm                  { padding: .3rem .65rem; font-size: .8125rem; }
.btn--full                { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }

.form-label {
    font-family: var(--font-body);
    font-size: .8125rem;
    color: var(--color-text-muted);
    font-weight: 600;
}

.form-input {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    padding: .5rem .75rem;
    font-family: var(--font-body);
    font-size: .875rem;
    width: 100%;
    transition: border-color .15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 71, 171, .1);
}

.form-input--sm { padding: .3rem .6rem; width: auto; }

/* ── Alerts ──────────────────────────────────────────────────────────────────── */
.alert {
    padding: .65rem 1rem;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: .875rem;
    margin-bottom: 1rem;
}

.alert--error   { background: #FEF2F2; border: 1px solid #FECACA; color: var(--color-error); }
.alert--warning { background: #FFFBEB; border: 1px solid #FDE68A; color: var(--color-warning); }
.alert--success { background: #F0FDF4; border: 1px solid #BBF7D0; color: var(--color-success); }

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

.login-wrapper { width: 100%; max-width: 380px; padding: 1rem; }

.login-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) * 2);
    padding: 2rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.login-card__header   { text-align: center; margin-bottom: 1.75rem; }
.login-card__title    { font-family: var(--font-heading); font-size: 1.35rem; font-weight: 700; color: #000000; }
.login-card__subtitle { font-family: var(--font-body); color: var(--color-text-muted); font-size: .875rem; margin-top: .25rem; }

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-body);
    font-size: .875rem;
}

.data-table th,
.data-table td {
    padding: .65rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.data-table th {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: .6875rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #000000;
    background: var(--color-surface);
}

.data-table tbody tr:hover { background: #F9FAFB; }

.table-empty {
    text-align: center;
    color: var(--color-text-muted);
    padding: 2rem !important;
    font-family: var(--font-body);
}

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 99px;
    font-family: var(--font-body);
    font-size: .75rem;
    font-weight: 600;
}

.badge--green { background: #DCFCE7; color: #15803D; }
.badge--gray  { background: #F3F4F6; color: #6B7280; }

.badge--estado-abierto      { background: #EFF6FF; color: #1D4ED8; }
.badge--estado-en_progreso  { background: #FFFBEB; color: #B45309; }
.badge--estado-en_revision  { background: #F0F9FF; color: #0369A1; }
.badge--estado-cerrado      { background: #DCFCE7; color: #15803D; }
.badge--estado-cancelado    { background: #F3F4F6; color: #6B7280; }

.badge--prioridad-baja    { background: #DCFCE7; color: #15803D; }
.badge--prioridad-media   { background: #FFFBEB; color: #B45309; }
.badge--prioridad-alta    { background: #FEF2F2; color: #DC2626; }
.badge--prioridad-urgente { background: #DC2626; color: #FFFFFF; }

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

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) * 2);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.stat-card__label { font-family: var(--font-body); font-size: .8125rem; color: var(--color-text-muted); }
.stat-card__value { font-family: var(--font-heading); font-size: 2rem; font-weight: 700; color: #000000; line-height: 1; }

/* ── Filter bar ──────────────────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: .75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

/* ── Gantt ───────────────────────────────────────────────────────────────────── */
.gantt-toolbar { margin-bottom: 1rem; }
#gantt-container { overflow-x: auto; }

/* — Table links — */
.table-link {
    color: #0047AB;
    font-family: 'Ubuntu Sans Mono', monospace;
    font-size: 0.8rem;
    text-decoration: none;
}
.table-link:hover {
    text-decoration: underline;
}
.table-empty-cell {
    color: #9CA3AF;
}

/* — Project row states — */
tr.row--yellow { background-color: #FEFCE8; }
tr.row--blue   { background-color: #EFF6FF; }
tr.row--green  { background-color: #F0FDF4; }

/* ── Projects section ────────────────────────────────────────────────────────── */
.projects-section {
    margin-top: 2rem;
}

.projects-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.projects-section__title {
    font-family: 'Ubuntu Sans', sans-serif;
    font-size: 1.25rem;
    color: #000000;
    margin: 0;
}

.sync-feedback {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.875rem;
}

.sync-feedback--ok {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.sync-feedback--error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}
