/* HytteOS - Norwegian portal-inspired design (Norge.no / NAV / Husleie.no) */

:root {
    --green:        #1a6b3a;
    --green-d:      #145530;
    --green-light:  #e8f5ec;
    --blue:         #0066cc;
    --blue-light:   #e8f0fa;
    --navy:         #1a2332;   /* dark footer, like NAV */
    --danger:       #c0392b;
    --danger-light: #fdf2f2;
    --success:      #1a6b3a;
    --success-light:#e8f5ec;
    --warning-bg:   #fff8e6;
    --warning-text: #7a5200;

    --bg:       #f5f5f5;       /* very light gray - NAV / Norge.no style */
    --surface:  #ffffff;
    --border:   #d6d6d6;
    --text:     #1a1a1a;
    --muted:    #5c5c5c;

    --font: 'Source Sans Pro', 'Segoe UI', Arial, sans-serif;
    --radius: 4px;
    --max-w:  1160px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 17px; }

body {
    font-family: var(--font);
    background:  var(--bg);
    color:       var(--text);
    line-height: 1.6;
    min-height:  100vh;
    display:     flex;
    flex-direction: column;
}

/* ── Typography ── */
h1 { font-size: 2rem;    font-weight: 700; line-height: 1.2; margin-bottom: .6rem; }
h2 { font-size: 1.45rem; font-weight: 700; line-height: 1.3; margin-bottom: .5rem; }
h3 { font-size: 1.15rem; font-weight: 600; margin-bottom: .3rem; }
p  { margin-bottom: 1rem; color: var(--text); }
a  { color: var(--blue); }
a:hover { color: var(--green); }
strong { font-weight: 700; }

/* ── Layout ── */
.container {
    max-width: var(--max-w);
    margin:    0 auto;
    padding:   0 1.5rem;
}

/* ── Header / Nav (Husleie.no style - green bar) ── */
.site-header {
    background: var(--green);
    color: #fff;
    padding: 0;
    border-bottom: 3px solid var(--green-d);
    position: relative;
}

.site-header .inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    text-decoration: none;
    letter-spacing: -.5px;
}
.logo span { color: #a8ddb5; }

.site-nav { display: flex; gap: 0; align-items: stretch; height: 64px; }

.site-nav a {
    display: flex;
    align-items: center;
    padding: 0 1.1rem;
    color: rgba(255,255,255,.88);
    text-decoration: none;
    font-weight: 600;
    font-size: .95rem;
    border-bottom: 3px solid transparent;
    margin-bottom: -3px;
    transition: color .12s, border-color .12s;
}
.site-nav a:hover,
.site-nav a.active {
    color: #fff;
    border-bottom-color: #a8ddb5;
}

.site-nav .nav-logout {
    color: rgba(255,255,255,.7);
    font-weight: 400;
    margin-left: .5rem;
}

/* ── Main content ── */
.site-main { flex: 1; padding: 2.5rem 0 3rem; }

/* ── Page title bar ── */
.page-title {
    margin-bottom: 2rem;
}
.page-title h1 { margin-bottom: .2rem; }
.page-title p  { color: var(--muted); margin: 0; font-size: 1rem; }

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid var(--green);
}
.card-header h2, .card-header h3 { margin: 0; }

/* ── Buttons (Norge.no / NAV style - solid, clear, accessible) ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .7rem 1.6rem;
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font);
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    line-height: 1.3;
    transition: background .12s, color .12s, border-color .12s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
}
.btn-primary:hover {
    background: var(--green-d);
    border-color: var(--green-d);
    color: #fff;
}

.btn-secondary {
    background: var(--surface);
    color: var(--green);
    border-color: var(--green);
}
.btn-secondary:hover {
    background: var(--green-light);
}

.btn-ghost {
    background: transparent;
    color: var(--blue);
    border-color: transparent;
    padding-left: .4rem;
    padding-right: .4rem;
}
.btn-ghost:hover { text-decoration: underline; color: var(--green); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #a02020; border-color: #a02020; }

.btn-lg { padding: .9rem 2.2rem; font-size: 1.1rem; }
.btn-sm { padding: .4rem 1rem; font-size: .88rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ── */
.form-group { margin-bottom: 1.35rem; }

label {
    display: block;
    font-weight: 600;
    margin-bottom: .35rem;
    font-size: .95rem;
}

input[type=text],
input[type=email],
input[type=password],
input[type=date],
input[type=number],
select,
textarea {
    width: 100%;
    padding: .7rem .9rem;
    font-size: 1rem;
    font-family: var(--font);
    border: 2px solid #b0b0b0;
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    transition: border-color .12s, box-shadow .12s;
    appearance: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0,102,204,.15);
}
input.input-error, select.input-error {
    border-color: var(--danger);
}

textarea { min-height: 90px; resize: vertical; }
.form-hint { font-size: .85rem; color: var(--muted); margin-top: .25rem; }
.field-error { font-size: .85rem; color: var(--danger); margin-top: .25rem; font-weight: 600; }

/* ── Alerts / Flash messages ── */
.alert {
    padding: .9rem 1.1rem;
    border-radius: var(--radius);
    border: 1px solid;
    border-left: 4px solid;
    margin-bottom: 1.25rem;
    font-size: .97rem;
}
.alert-error   { background: var(--danger-light); border-color: var(--danger); color: #7b1c1c; }
.alert-success { background: var(--success-light); border-color: var(--success); color: #155022; }
.alert-info    { background: var(--blue-light); border-color: var(--blue); color: #003f80; }
.alert-warning { background: var(--warning-bg); border-color: #c98a00; color: var(--warning-text); }

/* ── Tables ── */
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th {
    text-align: left;
    padding: .65rem .85rem;
    background: var(--bg);
    font-weight: 700;
    font-size: .88rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    border-bottom: 2px solid var(--border);
}
.table td {
    padding: .75rem .85rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f9f9f9; }

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: .2rem .65rem;
    border-radius: 100px;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.badge-owner   { background: var(--green-light); color: #145530; }
.badge-member  { background: var(--blue-light);  color: #003f80; }
.badge-paid    { background: var(--green-light);  color: #145530; }
.badge-unpaid  { background: #fde8e8; color: #7b1c1c; }

/* ── Stat boxes (dashboard) ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem;
    text-align: center;
    border-top: 3px solid var(--green);
}
.stat-num   { font-size: 2.2rem; font-weight: 800; color: var(--green); line-height: 1; }
.stat-label { font-size: .85rem; color: var(--muted); margin-top: .3rem; }

/* ── Nav tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab {
    padding: .65rem 1.25rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: .95rem;
}
.tab:hover { color: var(--green); }
.tab.active { color: var(--green); border-bottom-color: var(--green); }

/* ── Calendar (booking) ── */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}
.cal-day-header {
    text-align: center;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    padding: .4rem 0;
    letter-spacing: .04em;
}
.cal-day {
    min-height: 70px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .4rem;
    font-size: .85rem;
    position: relative;
    cursor: pointer;
    transition: background .1s;
}
.cal-day:hover { background: var(--green-light); }
.cal-day.other-month { background: #f0f0f0; color: var(--muted); cursor: default; }
.cal-day.today { border-color: var(--blue); }
.cal-day .day-num { font-weight: 700; font-size: .9rem; margin-bottom: .2rem; }
.cal-booking {
    background: var(--green);
    color: #fff;
    border-radius: 2px;
    padding: 1px 4px;
    font-size: .72rem;
    font-weight: 600;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cal-booking.conflict { background: var(--danger); }

/* ── Split layout (auth pages) ── */
.auth-wrap {
    max-width: 480px;
    margin: 2rem auto;
}
.auth-wrap .card { padding: 2.5rem; }
.auth-logo-big {
    text-align: center;
    margin-bottom: 1.5rem;
}
.auth-logo-big .wordmark {
    font-size: 2rem;
    font-weight: 800;
    color: var(--green);
    letter-spacing: -1px;
}
.auth-logo-big .wordmark span { color: var(--muted); }
.auth-logo-big p { color: var(--muted); font-size: .95rem; margin: .3rem 0 0; }

/* ── Footer (dark nav - NAV.no style) ── */
.site-footer {
    background: var(--navy);
    color: rgba(255,255,255,.75);
    padding: 2.5rem 0 1.5rem;
    margin-top: auto;
    font-size: .9rem;
}
.site-footer a { color: rgba(255,255,255,.75); text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}
.footer-brand .wordmark {
    font-size: 1.3rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.5px;
    display: block;
    margin-bottom: .5rem;
}
.footer-brand p {
    color: rgba(255,255,255,.65);
    margin: 0;
}
.footer-brand .wordmark span { color: #a8ddb5; }
.footer-col h4 {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: rgba(255,255,255,.5);
    margin-bottom: .75rem;
}
.footer-col ul { list-style: none; }
.footer-col ul li { margin-bottom: .4rem; }
.footer-bottom {
    border-top: 1px solid rgba(255,255,255,.12);
    padding-top: 1rem;
    font-size: .82rem;
    color: rgba(255,255,255,.4);
}

/* ── Utilities ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; }

/* Sidebar layouts — used by bookings and expenses pages */
.layout-sidebar { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; align-items: start; }
.layout-sidebar-sm { display: grid; grid-template-columns: 1fr 320px; gap: 1.5rem; align-items: start; }

/* Table scroll wrapper — prevents horizontal page overflow on mobile */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap .table { min-width: 500px; }

/* Calendar scroll wrapper */
.cal-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cal-scroll .cal-grid { min-width: 420px; }

/* ── Hamburger nav toggle ── */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: .4rem;
    color: #fff;
    flex-direction: column;
    gap: 5px;
}
.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
}

/* Mobile nav dropdown */
.site-nav.nav-open {
    display: flex !important;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    height: auto !important;
    background: var(--green-d);
    z-index: 100;
    padding: .5rem 0;
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.site-nav.nav-open a {
    padding: .85rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    border-left: none;
    border-bottom-color: transparent;
    margin: 0;
}
.site-nav.nav-open a:last-child { border-bottom: none; }

/* ── Responsive breakpoints ── */
@media (max-width: 768px) {
    .layout-sidebar,
    .layout-sidebar-sm  { grid-template-columns: 1fr; }

    /* page title + button stack vertically, buttons stay right */
    .page-title.flex-between { flex-direction: column; align-items: flex-start; gap: .75rem; }
    .page-title.flex-between > div:last-child { align-self: flex-end; }

    /* card headers stay side-by-side but allow wrap */
    .card-header { flex-wrap: wrap; gap: .5rem; }

    /* balance grid already uses auto-fit so it's fine */
}

@media (max-width: 640px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .footer-brand { grid-column: 1 / -1; margin-bottom: .25rem; }
    .stats-grid { gap: .5rem; }
    .stat-box { padding: 1rem .75rem; }
    .stat-num  { font-size: 1.7rem; }
    .site-nav { display: none; }
    .nav-toggle { display: flex; }
    h1 { font-size: 1.4rem; }
    .site-main { padding: 1.5rem 0 2rem; }
    .card { padding: 1.25rem; }
    .container { padding: 0 1rem; }
    .btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }

    /* hide secondary table columns on mobile */
    .col-hide-mobile { display: none; }

    /* calendar stays scrollable, reduce cell height */
    .cal-day { min-height: 52px; }
    .cal-day .day-num { font-size: .8rem; }
    .cal-booking { font-size: .68rem; padding: 1px 3px; }

    /* auth pages */
    .auth-wrap { margin: 1rem auto; }
    .auth-wrap .card { padding: 1.5rem; }

    /* cabin table → cards on mobile */
    .table-cabins thead { display: none; }
    .table-cabins,
    .table-cabins tbody { display: block; }
    .table-cabins tr {
        display: flex;
        align-items: center;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: .9rem 1rem;
        margin-bottom: .6rem;
        background: var(--surface);
    }
    .table-cabins td { border: none; padding: 0; }
    .table-cabins td.col-hide-mobile { display: none; }
    .table-cabins .cabin-name { flex: 1; font-size: 1.05rem; font-weight: 700; }
    .table-cabins .td-actions { display: none; }
}
.flex         { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; justify-content: center; align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted   { color: var(--muted); }
.text-sm      { font-size: .9rem; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-green   { color: var(--green); font-weight: 700; }
.w-full { width: 100%; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
