/* ============================================================
   style.css — ระบบสหกรณ์นักเรียน
   โรงเรียนชุมชนดงมะไฟเจริญศิลป์
   ============================================================ */

/* ---------- Google Fonts: Sarabun (ภาษาไทย) ---------- */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

/* ---------- CSS Variables ---------- */
:root {
    --primary:       #1d4ed8;   /* น้ำเงิน */
    --primary-dark:  #1e40af;
    --primary-light: #dbeafe;
    --secondary:     #0d9488;   /* เขียวน้ำทะเล */
    --success:       #16a34a;
    --warning:       #d97706;
    --danger:        #dc2626;
    --bg:            #f1f5f9;
    --surface:       #ffffff;
    --border:        #e2e8f0;
    --text:          #1e293b;
    --text-muted:    #64748b;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow:        0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
    --shadow-md:     0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
    --radius:        0.75rem;
    --radius-sm:     0.5rem;
    --radius-lg:     1rem;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Sarabun', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    margin: 0;
    padding: 0;
}

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

img { max-width: 100%; height: auto; }

/* ---------- Navigation ---------- */
.navbar {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #fff;
    padding: 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.25rem;
    height: 60px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
}

.navbar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.navbar-nav a {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    transition: background .15s, color .15s;
}

.navbar-nav a:hover,
.navbar-nav a.active {
    background: rgba(255,255,255,.18);
    color: #fff;
    text-decoration: none;
}

.navbar-nav .nav-logout a {
    color: rgba(255,200,200,.9);
}
.navbar-nav .nav-logout a:hover {
    background: rgba(220,38,38,.25);
    color: #fca5a5;
}

.navbar-user {
    font-size: 0.85rem;
    color: rgba(255,255,255,.7);
    margin-right: 0.5rem;
}

/* ---------- Layout / Wrapper ---------- */
.page-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

/* ---------- Page Header ---------- */
.page-header {
    margin-bottom: 1.5rem;
}
.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.page-header p {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.95rem;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1rem;
    background: #fafbfc;
}

.card-body {
    padding: 1.25rem;
}

/* ---------- Stat Cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform .15s, box-shadow .15s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.stat-icon.blue   { background: var(--primary-light); }
.stat-icon.green  { background: #dcfce7; }
.stat-icon.amber  { background: #fef3c7; }
.stat-icon.teal   { background: #ccfbf1; }

.stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.15rem;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.stat-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
}

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

label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 0.4rem;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 0.65rem 0.9rem;
    font-family: 'Sarabun', sans-serif;
    font-size: 1rem;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}

input::placeholder,
textarea::placeholder { color: #94a3b8; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.4rem;
    font-family: 'Sarabun', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: opacity .15s, transform .1s, box-shadow .15s;
    white-space: nowrap;
}

.btn:hover   { opacity: .88; text-decoration: none; }
.btn:active  { transform: scale(.97); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 4px rgba(29,78,216,.3);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
    background: var(--success);
    color: #fff;
    box-shadow: 0 2px 4px rgba(22,163,74,.3);
}

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

.btn-secondary {
    background: #f1f5f9;
    color: var(--text);
    border: 1.5px solid var(--border);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 0.85rem 2rem;
    font-size: 1.05rem;
}

.btn-block { width: 100%; }

/* ---------- Alerts ---------- */
.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    border-left: 4px solid transparent;
}
.alert-danger  { background: #fef2f2; color: #991b1b; border-color: var(--danger); }
.alert-success { background: #f0fdf4; color: #166534; border-color: var(--success); }
.alert-warning { background: #fffbeb; color: #92400e; border-color: var(--warning); }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: var(--primary); }

/* ---------- Tables ---------- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

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

thead th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: var(--primary-light); color: var(--primary-dark); }

/* ---------- Login Page ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, var(--primary) 50%, var(--secondary) 100%);
    padding: 1.5rem;
}

.login-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
}

.login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}
.login-logo .logo-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 0.75rem;
    box-shadow: 0 4px 12px rgba(29,78,216,.35);
}
.login-logo h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.25rem;
    line-height: 1.3;
}
.login-logo p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

/* ---------- Receipt ---------- */
.receipt {
    max-width: 360px;
    margin: 1.5rem auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    font-size: 0.92rem;
}
.receipt-header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    padding: 1.25rem;
    text-align: center;
}
.receipt-header h2 { font-size: 1rem; margin: 0 0 .2rem; font-weight: 700; }
.receipt-header p  { font-size: 0.8rem; margin: 0; opacity: .85; }
.receipt-body { padding: 1.25rem; }
.receipt-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px dashed #e2e8f0;
}
.receipt-row:last-child { border-bottom: none; }
.receipt-total {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    border-top: 2px solid var(--border);
    padding-top: 0.75rem;
    margin-top: 0.25rem;
}
.receipt-footer {
    text-align: center;
    padding: 0.75rem 1.25rem 1.25rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    border-top: 1px solid var(--border);
}

/* ---------- POS Layout ---------- */
.pos-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.25rem;
    align-items: start;
}
@media (max-width: 768px) {
    .pos-grid { grid-template-columns: 1fr; }
}

.pos-cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0;
    border-bottom: 1px solid #f1f5f9;
    gap: 0.5rem;
}
.pos-cart-item:last-child { border-bottom: none; }

/* ---------- Dividend ---------- */
.dividend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    flex-wrap: wrap;
}
.dividend-row:last-child { border-bottom: none; }
.dividend-name { font-weight: 600; flex: 1; min-width: 120px; }
.dividend-amounts {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.dividend-amounts > div { text-align: right; }
.dividend-amounts .label {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.dividend-amounts .value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--success);
}

/* ---------- Chart wrapper ---------- */
.chart-wrapper {
    position: relative;
    height: 280px;
}

/* ---------- Utilities ---------- */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.fw-bold      { font-weight: 700; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .page-wrapper { padding: 1rem 0.75rem 2.5rem; }
    .navbar-brand span { display: none; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .login-box { padding: 1.75rem 1.25rem; }
    .navbar-nav a { padding: 0.4rem 0.6rem; font-size: 0.82rem; }
}

/* ---------- Print styles ---------- */
@media print {
    .navbar, .btn, .no-print { display: none !important; }
    body { background: #fff; font-size: 13px; }
    .receipt { box-shadow: none; border: 1px solid #ccc; }
    .page-wrapper { padding: 0; max-width: 100%; }
}
