/* ===== Noel Workshop MVP – Stylesheet ===== */

:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --green: #16a34a;
    --green-bg: #dcfce7;
    --blue: #2563eb;
    --blue-bg: #dbeafe;
    --orange: #ea580c;
    --orange-bg: #fff7ed;
    --red: #dc2626;
    --red-bg: #fee2e2;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 15px;
}

/* ===== Navbar ===== */
.navbar {
    display: flex;
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-brand a {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: .25rem;
    margin-left: 2rem;
}

.nav-links a {
    padding: .4rem .75rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-muted);
    font-size: .875rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.nav-links a:hover, .nav-links a.active {
    background: var(--bg);
    color: var(--text);
}

.nav-logout { color: var(--red) !important; }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 768px) {
    .nav-links { display: none; flex-direction: column; position: absolute; top: 56px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: .5rem; }
    .nav-links.open { display: flex; }
    .nav-toggle { display: block; }
}

/* ===== Container ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

/* ===== Typography ===== */
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .75rem; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; }
.subtitle { color: var(--text-muted); margin-bottom: 1rem; font-size: .9rem; }

/* ===== Flash messages ===== */
.flash {
    padding: .85rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .9rem;
    font-weight: 500;
    line-height: 1.5;
    border-left: 4px solid transparent;
}
.flash-error { background: var(--red-bg); color: var(--red); border-left-color: var(--red); }
.flash-success { background: var(--green-bg); color: var(--green); border-left-color: var(--green); }
.flash-info { background: var(--blue-bg); color: var(--blue); border-left-color: var(--blue); }
.flash-warning { background: var(--orange-bg); color: var(--orange); border-left-color: var(--orange); font-weight: 600; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    padding: .5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { opacity: .9; }
.btn-muted { color: var(--text-muted); }
.btn-sm { padding: .25rem .6rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ===== Auth card ===== */
.auth-card {
    max-width: 400px;
    margin: 4rem auto;
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.auth-card h1 { text-align: center; margin-bottom: 1.5rem; }
.auth-link { text-align: center; margin-top: 1rem; color: var(--text-muted); font-size: .875rem; }
.auth-link a { color: var(--primary); }

/* ===== Forms ===== */
.form-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 600px;
}

label {
    display: block;
    margin-bottom: 1rem;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    width: auto;
    display: inline-block;
    margin: 0;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"],
select, textarea {
    display: block;
    width: 100%;
    margin-top: .25rem;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    font-family: inherit;
    background: var(--surface);
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }

.form-row { display: flex; gap: 1rem; }
.form-row label { flex: 1; }

.form-actions { display: flex; gap: .75rem; margin-top: 1rem; }

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}
legend { font-weight: 600; font-size: .9rem; padding: 0 .5rem; }
.help-text { font-size: .8rem; color: var(--text-muted); }

/* ===== Vehicle fieldset ===== */
.vehicle-fieldset { margin-bottom: .75rem; }
.vehicle-fieldset label { display: inline-block; width: calc(33% - .5rem); margin-right: .25rem; }
@media (max-width: 600px) { .vehicle-fieldset label { width: 100%; } }

/* ===== Page header ===== */
.page-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }

/* ===== Search ===== */
.search-form { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search-form input { flex: 1; }

/* ===== Data tables ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    font-size: .875rem;
}
.data-table th {
    background: var(--bg);
    text-align: left;
    padding: .6rem .75rem;
    font-weight: 600;
    font-size: .8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}
.data-table td { padding: .6rem .75rem; border-top: 1px solid var(--border); }
.data-table tr:hover td { background: #f9fafb; }

/* ===== Category badges ===== */
.cat-badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
}
.cat-bg-green { background: var(--green-bg); color: var(--green); }
.cat-bg-blue { background: var(--blue-bg); color: var(--blue); }
.cat-bg-orange { background: var(--orange-bg); color: var(--orange); }
.cat-bg-red { background: var(--red-bg); color: var(--red); }

.cat-green { color: var(--green); font-weight: 700; }
.cat-blue { color: var(--blue); font-weight: 700; }
.cat-orange { color: var(--orange); font-weight: 700; }
.cat-red { color: var(--red); font-weight: 700; }

.cat-border-green { border-left: 3px solid var(--green); }
.cat-border-blue { border-left: 3px solid var(--blue); }
.cat-border-orange { border-left: 3px solid var(--orange); }
.cat-border-red { border-left: 3px solid var(--red); }

/* ===== Stat cards ===== */
.stat-cards { display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.stat-card {
    flex: 1;
    min-width: 120px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 700; }
.stat-label { font-size: .8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

/* ===== Load bars ===== */
.load-bars { margin-bottom: 1.5rem; }
.load-bar-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; padding: .5rem .75rem; background: var(--surface); border-radius: var(--radius); }
.load-bar-row.overload { background: var(--red-bg); }
.load-label { width: 60px; font-weight: 700; font-size: .85rem; }
.load-bar-track { flex: 1; height: 18px; background: var(--bg); border-radius: 9px; position: relative; overflow: hidden; }
.load-bar-fill { height: 100%; border-radius: 9px; transition: width .3s; }
.load-bar-fill.cat-bg-green { background: var(--green); }
.load-bar-fill.cat-bg-blue { background: var(--blue); }
.load-bar-fill.cat-bg-orange { background: var(--orange); }
.load-bar-fill.cat-bg-red { background: var(--red); }
.load-value { font-size: .8rem; white-space: nowrap; }
.overload-badge { background: var(--red); color: #fff; padding: .1rem .4rem; border-radius: 4px; font-size: .7rem; font-weight: 700; }

/* ===== Week grid ===== */
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: .5rem; margin-bottom: 1.5rem; }
@media (max-width: 768px) { .week-grid { grid-template-columns: 1fr 1fr; } }
.week-day {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .75rem;
    min-height: 140px;
}
.week-day.today { border: 2px solid var(--primary); }
.week-day-header { display: flex; justify-content: space-between; margin-bottom: .5rem; font-size: .85rem; }
.week-day-header a { color: var(--primary); text-decoration: none; font-weight: 700; }
.week-day-load { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: .5rem; }
.mini-load { padding: .1rem .3rem; border-radius: 3px; font-size: .65rem; font-weight: 700; }
.mini-load.overload { outline: 2px solid var(--red); }
.week-day-appts { font-size: .8rem; }
.week-appt { padding: .25rem .4rem; margin-bottom: .25rem; border-radius: 4px; background: var(--bg); }
.week-appt .time { font-weight: 600; }
.week-appt .svc { color: var(--text-muted); }
.week-empty { color: var(--text-muted); font-size: .8rem; }

/* ===== Hourly grid ===== */
.hour-grid { margin-bottom: 1.5rem; }
.hour-row { display: flex; border-bottom: 1px solid var(--border); min-height: 40px; }
.hour-label { width: 60px; padding: .5rem .25rem; font-size: .8rem; font-weight: 600; color: var(--text-muted); flex-shrink: 0; }
.hour-slots { flex: 1; display: flex; gap: .25rem; flex-wrap: wrap; padding: .25rem 0; }
.hour-appt {
    display: inline-block;
    padding: .2rem .5rem;
    border-radius: 4px;
    font-size: .8rem;
    text-decoration: none;
    color: var(--text);
}
.hour-appt.cat-bg-green { background: var(--green-bg); }
.hour-appt.cat-bg-blue { background: var(--blue-bg); }
.hour-appt.cat-bg-orange { background: var(--orange-bg); }
.hour-appt.cat-bg-red { background: var(--red-bg); }

/* ===== Status badges ===== */
.status-badge { padding: 2px 8px; border-radius: 4px; font-size: 13px; font-weight: 500; }
.status-en_curso { background: #dbeafe; color: #2563eb; }
.status-finalizado { background: #dcfce7; color: #16a34a; }

/* ===== Non-working / break hours ===== */
.hour-row-break {
    background: #f0f0f0;
    opacity: .6;
}
.hour-row-break .hour-label {
    color: var(--text-muted);
}
.break-label {
    display: block;
    font-size: .65rem;
    font-weight: 400;
    color: var(--text-muted);
}

/* ===== Worker-lane hourly grid ===== */
.hour-grid-workers { margin-bottom: 1.5rem; overflow-x: auto; }
.hour-grid-header {
    display: flex;
    border-bottom: 2px solid var(--border);
    font-size: .8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}
.hour-grid-header .hour-label { width: 70px; flex-shrink: 0; padding: .5rem .25rem; }
.worker-lane-header {
    flex: 1;
    min-width: 120px;
    padding: .5rem .25rem;
    text-align: center;
    border-left: 1px solid var(--border);
}
.hour-grid-workers .hour-row {
    display: flex;
    border-bottom: 1px solid var(--border);
    min-height: 40px;
}
.hour-grid-workers .hour-label {
    width: 70px;
    flex-shrink: 0;
    padding: .5rem .25rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
}
.hour-lane {
    flex: 1;
    min-width: 120px;
    border-left: 1px solid var(--border);
    padding: .25rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

/* ===== Worker tag ===== */
.worker-tag {
    display: inline-block;
    background: var(--blue-bg);
    color: var(--blue);
    padding: .1rem .35rem;
    border-radius: 3px;
    font-size: .7rem;
    font-weight: 600;
    margin-left: .25rem;
}
.worker-tag-sm {
    display: block;
    font-size: .7rem;
    color: var(--primary);
    font-weight: 600;
}

/* ===== Autocomplete ===== */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    z-index: 50;
    max-height: 220px;
    overflow-y: auto;
}
.autocomplete-item {
    padding: .5rem .75rem;
    cursor: pointer;
    font-size: .875rem;
    border-bottom: 1px solid var(--border);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg); }

/* ===== Multi-service rows ===== */
.services-fieldset { border-color: var(--primary); }
.service-row {
    display: flex;
    gap: .5rem;
    align-items: center;
    margin-bottom: .5rem;
}
.service-row .service-filter-input {
    width: 160px;
    flex-shrink: 0;
    margin-top: 0;
}
.service-row .service-select {
    flex: 1;
    margin-top: 0;
}
.service-row .btn { flex-shrink: 0; }
@media (max-width: 600px) {
    .service-row {
        flex-wrap: wrap;
    }
    .service-row .service-filter-input { width: 100%; }
    .service-row .service-select { width: 100%; }
}

/* ===== Work interval settings grid ===== */
.intervals-grid { }
.interval-day-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .5rem;
    flex-wrap: wrap;
}
.interval-day-label {
    width: 100px;
    flex-shrink: 0;
    font-size: .85rem;
}
.interval-slot {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}
.interval-input {
    width: 100px !important;
    margin-top: 0 !important;
    padding: .35rem .5rem !important;
    font-size: .85rem !important;
}
.interval-dash {
    color: var(--text-muted);
    font-weight: 600;
}
@media (max-width: 600px) {
    .interval-day-row { flex-direction: column; align-items: flex-start; }
    .interval-input { width: 120px !important; }
}

/* ===== Misc ===== */
.quick-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.empty-state { text-align: center; padding: 2rem; color: var(--text-muted); }
.empty-state a { color: var(--primary); }
.vehicle-chip { display: inline-block; background: var(--bg); padding: .15rem .4rem; border-radius: 4px; font-size: .8rem; margin: .1rem; }
.nav-arrows { display: flex; align-items: center; gap: .5rem; }
.date-range { font-weight: 600; font-size: .9rem; }

.info-box {
    background: var(--blue-bg);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1rem;
    font-size: .875rem;
}
.info-box ul { margin-left: 1.5rem; margin-top: .25rem; }

.notif-type { padding: .15rem .4rem; border-radius: 4px; font-size: .7rem; font-weight: 700; }
.notif-ready { background: var(--green-bg); color: var(--green); }
.notif-prepayment { background: var(--blue-bg); color: var(--blue); }
.notif-reminder { background: #fef3c7; color: #92400e; }
.notif-text { max-width: 400px; white-space: pre-line; }

.split-fieldset { border-color: var(--blue); }

/* ===== Worker dashboard job cards ===== */
.worker-jobs { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.5rem; }
.worker-job-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    border-left: 4px solid var(--border);
}
.worker-job-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .5rem;
}
.worker-job-time { font-size: 1.25rem; font-weight: 700; }
.worker-job-body { margin-bottom: .75rem; }
.worker-job-client { font-size: 1rem; margin-bottom: .15rem; }
.worker-job-vehicle { font-size: .875rem; color: var(--text-muted); }
.worker-job-services { font-size: .9rem; font-weight: 500; margin-top: .25rem; }
.worker-job-duration { font-size: .85rem; color: var(--text-muted); }
.worker-job-notes { font-size: .85rem; color: var(--text-muted); margin-top: .35rem; font-style: italic; }
.worker-job-materials { margin-top: .5rem; font-size: .85rem; }
.material-chip {
    display: inline-block;
    background: var(--bg);
    padding: .1rem .4rem;
    border-radius: 4px;
    font-size: .8rem;
    margin: .1rem;
}
.worker-job-actions { display: flex; gap: .5rem; }

/* ===== Actual hours display ===== */
.actual-hours-list { font-size: .8rem; margin-top: .25rem; }
.actual-hours-item { display: inline-block; margin-right: .75rem; }
.actual-hours-item .svc-name { color: var(--text-muted); }
.actual-hours-item .hours-val { font-weight: 600; }

/* ===== Materials fieldset polish ===== */
.materials-fieldset { border-color: var(--orange); }
.material-row { animation: fadeIn .2s ease-in; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ===== Language switcher ===== */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: .25rem;
    margin-left: auto;
    margin-right: .75rem;
    font-size: .8rem;
    font-weight: 600;
}
.lang-switcher-auth {
    position: fixed;
    top: 1rem;
    right: 1.5rem;
    z-index: 200;
    background: var(--surface);
    padding: .35rem .6rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.lang-active {
    color: var(--primary);
    padding: .2rem .4rem;
    background: var(--blue-bg);
    border-radius: 4px;
}
.lang-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: .2rem .4rem;
    border-radius: 4px;
    transition: background .15s, color .15s;
}
.lang-link:hover {
    background: var(--bg);
    color: var(--text);
}
