/* =============================================================
   Mahlamaailma tellimussüsteem – stiilid
   Värvid: mahlamaailm.ee põhjal
   ============================================================= */


/* --- Muutujad --- */
:root {
    --primary:       #227D43;
    --primary-dark:  #1a6234;
    --primary-light: #e8f5ee;
    --green:         #227D43;
    --green-light:   #e8f5ee;
    --red:           #dc2626;
    --red-light:     #fee2e2;
    --amber:         #d97706;
    --amber-light:   #fef3c7;
    --body-bg:       #ffffff;
    --gray-50:       #f4f9f1;
    --gray-100:      #edf5e8;
    --gray-200:      #d4e4cc;
    --gray-400:      #8aaa80;
    --gray-600:      #4d6b46;
    --gray-800:      #3a3a3a;
    --white:         #ffffff;
    --radius:        6px;
    --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md:     0 4px 12px rgba(34,125,67,.1);
}

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

body {
    margin: 0;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 15px;
    color: var(--gray-800);
    background: var(--body-bg);
    line-height: 1.55;
}

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

h1 { font-size: 1.5rem; margin: 0 0 1.25rem; color: var(--primary); }
h2 { font-size: 1.15rem; margin: 0 0 1rem; color: var(--gray-800); }

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

.login-wrap { width: 100%; max-width: 380px; padding: 0 16px; }

.login-box {
    background: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    padding: 2.25rem 2rem;
    border-top: 4px solid var(--primary);
}

.login-logo {
    display: block;
    margin: 0 auto 1.25rem;
    max-width: 140px;
    height: auto;
}

.login-box h1 {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--gray-600);
    letter-spacing: .01em;
}

/* --- Päis (valge, rohelise alt-äärena) --- */
.site-header {
    background: var(--white);
    border-bottom: 3px solid var(--primary);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(34,125,67,.08);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.site-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.site-logo img {
    height: 42px;
    width: auto;
}

.site-logo:hover { opacity: .85; text-decoration: none; }

.main-nav {
    display: flex;
    align-items: center;
    gap: .25rem;
    flex-wrap: wrap;
    flex: 1;
}

.main-nav a {
    color: var(--gray-600);
    padding: 6px 13px;
    border-radius: var(--radius);
    font-size: .88rem;
    font-weight: 600;
    letter-spacing: .02em;
    transition: background .15s, color .15s;
}

.main-nav a:hover,
.main-nav a.active {
    background: var(--primary-light);
    color: var(--primary);
    text-decoration: none;
}

.nav-logout {
    margin-left: auto;
    font-size: .83rem;
    color: var(--gray-400) !important;
    font-weight: 400;
}
.nav-logout:hover { color: var(--primary) !important; }

/* --- Põhisisu --- */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.75rem 1.5rem;
}

/* --- Kaart --- */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 1rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--gray-200);
    color: var(--primary);
}

/* --- Tabel --- */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

th {
    background: var(--gray-50);
    font-weight: 700;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--gray-600);
    white-space: nowrap;
}

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

td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }

/* --- Staatuse sildid --- */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 12px;
    font-size: .77rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.badge-uus       { background: #dbeafe; color: #1e40af; }
.badge-tootluses { background: #fef3c7; color: #92400e; }
.badge-taidetud  { background: var(--green-light); color: var(--primary-dark); }

/* --- Nupud --- */
.btn {
    display: inline-block;
    padding: 8px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: .88rem;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: .02em;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, box-shadow .15s;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-primary   { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; box-shadow: 0 2px 6px rgba(34,125,67,.3); }

.btn-secondary { background: var(--white); color: var(--gray-800); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); text-decoration: none; }

.btn-danger    { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #b91c1c; text-decoration: none; }

.btn-sm    { padding: 4px 11px; font-size: .81rem; }
.btn-block { display: block; width: 100%; text-align: center; }

/* --- Vormid --- */
.form-group { margin-bottom: 1rem; }

label {
    display: block;
    font-size: .875rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--gray-800);
    letter-spacing: .01em;
}

label .hint {
    font-weight: 400;
    color: var(--gray-600);
    font-size: .8rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
    display: block;
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
}

input[type="number"] { max-width: 120px; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(34,125,67,.12);
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: .75rem;
    align-items: center;
}

/* --- Teavitused --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: .9rem;
}

.alert-success { background: var(--green-light);  border: 1px solid #a7d4b5; color: var(--primary-dark); }
.alert-error   { background: var(--red-light);    border: 1px solid #fca5a5; color: #7f1d1d; }
.alert-info    { background: #fffbeb;             border: 1px solid #fcd34d; color: #78350f; }
.alert-warning { background: var(--amber-light);  border: 1px solid #fcd34d; color: #78350f; }

/* --- Lehe päis koos nupuga --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h1 { margin: 0; }

/* --- Tellimuse staatuse vorm --- */
.status-form { display: flex; gap: .5rem; align-items: center; }

/* --- Toote pilt --- */
.product-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--gray-200);
}

.product-thumb-placeholder {
    width: 56px;
    height: 56px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    font-size: .7rem;
}

/* --- Koguse sisestus tellimuse vormis --- */
.order-table input[type="number"] {
    width: 80px;
    text-align: right;
    padding: 6px 8px;
}

.order-total-row td {
    font-weight: 700;
    font-size: 1rem;
    background: var(--gray-50);
    border-top: 2px solid var(--gray-200);
}

#grand-total {
    font-size: 1.15rem;
    color: var(--primary);
}

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal-box {
    background: var(--white);
    border-radius: 10px;
    box-shadow: 0 20px 40px rgba(0,0,0,.2);
    border-top: 4px solid var(--primary);
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.75rem;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--gray-400);
    line-height: 1;
    padding: 4px;
    font-family: inherit;
}
.modal-close:hover { color: var(--primary); }

.modal-box h2 { margin: 0 2rem 1rem 0; color: var(--primary); }

.modal-img {
    width: 100%;
    max-height: 240px;
    object-fit: contain;
    border-radius: 4px;
    margin-bottom: 1rem;
    background: var(--gray-50);
}

.detail-row { margin-bottom: .75rem; }

.detail-label {
    font-size: .77rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--primary);
    margin-bottom: 2px;
}

.detail-value {
    font-size: .9rem;
    color: var(--gray-800);
    white-space: pre-wrap;
}

/* --- Jalus --- */
.site-footer {
    text-align: center;
    padding: 1.5rem;
    font-size: .82rem;
    color: var(--gray-400);
    margin-top: 2rem;
    border-top: 1px solid var(--gray-200);
}

/* --- Lisainfo-nupp --- */
.btn-info {
    background: none;
    border: 1px solid var(--gray-200);
    color: var(--primary);
    padding: 3px 8px;
    border-radius: var(--radius);
    font-size: .79rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}
.btn-info:hover { background: var(--primary-light); border-color: var(--primary); }

/* --- Hinnatabel admin/prices.php --- */
.price-input {
    width: 110px !important;
    text-align: right;
}

.price-base {
    font-size: .82rem;
    color: var(--gray-400);
    margin-top: 2px;
}

/* --- Väike tekst --- */
.text-muted { color: var(--gray-600); font-size: .875rem; }
.text-right { text-align: right; }

/* --- Filtri vorm --- */
.filter-bar {
    display: flex;
    gap: .75rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.filter-bar .form-group { margin: 0; }
.filter-bar label { font-size: .8rem; }
.filter-bar select { min-width: 140px; padding: 7px 10px; }
