/* ============================================================
   GP Manyachiwadi GIS Portal - Design System
   Warm civic-tech aesthetic • Mobile-first
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Anek+Devanagari:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Forest-civic palette */
    --forest-950: #052e2b;
    --forest-900: #064e3b;
    --forest-800: #065f46;
    --forest-700: #047857;
    --forest-600: #059669;
    --forest-500: #10b981;
    --forest-400: #34d399;
    --forest-100: #d1fae5;
    --forest-50:  #ecfdf5;

    --earth-900: #451a03;
    --earth-700: #92400e;
    --earth-500: #d97706;
    --earth-300: #fcd34d;
    --earth-100: #fef3c7;

    --cream:     #fefce8;
    --paper:     #fffdf7;
    --ink:       #1c1917;
    --ink-soft:  #44403c;
    --ink-mute:  #78716c;
    --border:    #e7e5e4;
    --border-soft: #f5f5f4;

    --danger:  #dc2626;
    --success: #16a34a;
    --warning: #f59e0b;
    --info:    #0284c7;

    --shadow-sm: 0 1px 2px rgba(6, 78, 59, 0.05);
    --shadow-md: 0 4px 12px rgba(6, 78, 59, 0.08);
    --shadow-lg: 0 12px 32px rgba(6, 78, 59, 0.12);
    --shadow-xl: 0 24px 60px rgba(6, 78, 59, 0.18);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --font-display: 'Fraunces', Georgia, serif;
    --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mr:      'Anek Devanagari', 'Inter', sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* Marathi text utility */
.mr, [lang="mr"] {
    font-family: var(--font-mr);
}

/* Typography */
h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--forest-900);
    letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); line-height: 1.15; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); line-height: 1.2; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }

a { color: var(--forest-700); text-decoration: none; }
a:hover { color: var(--forest-600); }

/* ===== Layout Primitives ===== */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

.grid { display: grid; gap: 20px; }
.flex { display: flex; gap: 12px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}
.btn-primary {
    background: var(--forest-700);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
    background: var(--forest-800);
    color: #fff;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.btn-secondary {
    background: var(--forest-50);
    color: var(--forest-800);
    border: 1.5px solid var(--forest-100);
}
.btn-secondary:hover { background: var(--forest-100); }
.btn-outline {
    background: transparent;
    color: var(--forest-700);
    border: 1.5px solid var(--forest-700);
}
.btn-outline:hover { background: var(--forest-700); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn-block { width: 100%; }

/* ===== Cards ===== */
.card {
    background: #fff;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-soft);
}
.card-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    color: var(--forest-900);
}

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 15px;
    background: #fff;
    color: var(--ink);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--forest-600);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-help { font-size: 12px; color: var(--ink-mute); margin-top: 4px; }

/* ===== Flash messages ===== */
.flash {
    padding: 12px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    border-left: 4px solid;
    animation: slideDown 0.3s ease;
}
.flash-success { background: var(--forest-50); color: var(--forest-900); border-color: var(--success); }
.flash-error { background: #fef2f2; color: #7f1d1d; border-color: var(--danger); }
.flash-info { background: #eff6ff; color: #1e3a8a; border-color: var(--info); }
.flash-warning { background: #fffbeb; color: #78350f; border-color: var(--warning); }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Tables ===== */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
    background: #fff;
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th {
    background: var(--forest-50);
    color: var(--forest-900);
    font-weight: 600;
    text-align: left;
    padding: 12px 16px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--forest-100);
}
.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover { background: var(--forest-50); }

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-success { background: var(--forest-100); color: var(--forest-900); }
.badge-warning { background: #fef3c7; color: #78350f; }
.badge-danger  { background: #fee2e2; color: #7f1d1d; }
.badge-info    { background: #dbeafe; color: #1e3a8a; }
.badge-neutral { background: #f5f5f4; color: #44403c; }

/* ===== Loading ===== */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--forest-100);
    border-top-color: var(--forest-700);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Utilities ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-mute { color: var(--ink-mute); }
.text-small { font-size: 13px; }
.text-tiny { font-size: 12px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; } .mb-4 { margin-bottom: 32px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container { padding: 0 16px; }
    .card { padding: 18px; border-radius: var(--radius-md); }
    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.3rem; }
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0 0;
    margin-top: 16px;
    border-top: 1px solid var(--border-soft);
    flex-wrap: wrap;
    gap: 12px;
}
.pg-info { font-size: 13px; color: var(--ink-mute); }
.pg-links { display: flex; gap: 4px; }
.pg-btn {
    min-width: 36px;
    padding: 7px 12px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--forest-800);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}
.pg-btn:hover { background: var(--forest-50); }
.pg-btn.active { background: var(--forest-700); color: #fff; border-color: var(--forest-700); }

/* ===== Page toolbar ===== */
.page-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.page-toolbar .search-box {
    flex: 1;
    max-width: 340px;
    position: relative;
}
.page-toolbar .search-box input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: #fff;
    font-size: 14px;
}
.page-toolbar .search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-mute);
}
.toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--ink-mute);
}
.empty-state-icon {
    display: inline-flex;
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--forest-50);
    color: var(--forest-600);
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.empty-state h3 {
    font-family: var(--font-display);
    color: var(--forest-900);
    margin-bottom: 6px;
}
.empty-state p { font-size: 14px; }

/* ===== Action buttons in tables ===== */
.row-actions { display: flex; gap: 6px; }
.row-actions .icon-btn {
    width: 32px; height: 32px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--ink-soft);
    cursor: pointer;
    transition: all 0.15s;
}
.row-actions .icon-btn:hover { background: var(--forest-50); color: var(--forest-800); border-color: var(--forest-100); }
.row-actions .icon-btn.danger:hover { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(6, 78, 59, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: #fff;
    border-radius: var(--radius-xl);
    padding: 32px;
    max-width: 540px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.2s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-soft);
}
.modal-header h3 {
    font-family: var(--font-display);
    color: var(--forest-900);
    margin: 0;
}
.modal-close {
    background: none;
    border: none;
    color: var(--ink-mute);
    cursor: pointer;
    padding: 4px;
    display: flex;
}
.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px solid var(--border-soft);
}

/* ===== Form grids ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.form-grid .full { grid-column: 1 / -1; }

/* ===== Image preview ===== */
.img-thumb {
    width: 42px; height: 42px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border);
}
.img-preview {
    width: 100px; height: 100px;
    border-radius: var(--radius-md);
    object-fit: cover;
    border: 2px solid var(--border);
    display: block;
    margin-top: 8px;
}

/* Confirm dialog */
.confirm-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: inline;
}
