/* ═══════════════════════════════════════════════════════
   Župni Administrativni Sustav – Liturgijska Paleta
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Liturgijske boje / Brendiranje Župe */
    --primary: #0f172a;
    --primary-light: #1e293b;
    --primary-dark: #020617;
    --accent: #d97706;
    --accent-light: #f59e0b;

    /* Pozadine */
    --bg-body: #F5F3EF;
    --bg-card: #FFFFFF;
    --bg-sidebar: #1A1A2E;
    --bg-sidebar-hover: #252545;
    --bg-header: #FFFFFF;

    /* Tekst */
    --text-primary: #2D2D2D;
    --text-secondary: #6B7280;
    --text-sidebar: #CBD5E1;
    --text-sidebar-active: #FFD700;

    /* Status */
    --success: #2E7D32;
    --success-bg: #E8F5E9;
    --warning: #E65100;
    --warning-bg: #FFF3E0;
    --danger: #C62828;
    --danger-bg: #FFEBEE;
    --info: #1565C0;
    --info-bg: #E3F2FD;

    /* Borderi */
    --border: #E5E7EB;
    --border-light: #F3F4F6;

    /* Sjene */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);

    /* Dimenzije */
    --sidebar-width: 280px;
    --sidebar-collapsed: 80px;
    --header-height: 64px;
    --radius: 8px;
    --radius-lg: 12px;
}

/* ── Reset & Base ─────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-light);
}

/* ── Layout ───────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.page-content {
    padding: 24px;
    flex: 1;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    overflow-y: auto;
    z-index: 1000;
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}

.sidebar-subtitle {
    font-size: 11px;
    color: var(--text-sidebar);
    opacity: 0.6;
}

.sidebar-nav {
    padding: 12px 0;
    flex: 1;
}

.nav-group {
    margin-bottom: 8px;
}

.nav-group-label {
    padding: 8px 20px 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.3);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-sidebar);
    font-size: 13px;
    font-weight: 400;
    transition: all 0.2s;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: rgba(139, 0, 0, 0.2);
    color: var(--text-sidebar-active);
    border-left-color: var(--accent);
    font-weight: 500;
}

.nav-item .icon {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    flex-shrink: 0;
}

.nav-item.active .icon {
    opacity: 1;
}

.nav-sub {
    padding-left: 52px;
}

.nav-sub .nav-item {
    padding: 7px 20px 7px 0;
    font-size: 12.5px;
    border-left: none;
}

.nav-sub .nav-item::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.nav-sub .nav-item.active::before {
    background: var(--accent);
}

/* ── Header ───────────────────────────────────────────── */
.header {
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--text-secondary);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb .current {
    color: var(--text-primary);
    font-weight: 500;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}

.user-menu:hover {
    background: var(--border-light);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
}

.user-role {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ── User Dropdown ───────────────────────────────────── */
.user-dropdown {
    position: relative;
}

.user-menu {
    border: none;
    background: none;
    font-family: inherit;
    text-align: left;
}

.dropdown-chevron {
    color: var(--text-secondary);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.dropdown-chevron.rotated {
    transform: rotate(180deg);
}

.dropdown-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 6px;
    z-index: 1000;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s ease;
}

.dropdown-item:hover {
    background: var(--border-light);
}

.dropdown-item svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.dropdown-item-danger {
    color: var(--danger);
}

.dropdown-item-danger svg {
    color: var(--danger);
}

.dropdown-item-danger:hover {
    background: rgba(220, 53, 69, 0.08);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}

/* Dropdown Alpine.js transitions */
.dropdown-enter {
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.dropdown-enter-start {
    opacity: 0;
    transform: translateY(-4px) scale(0.97);
}

.dropdown-enter-end {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.dropdown-leave {
    transition: opacity 0.1s ease, transform 0.1s ease;
}

.dropdown-leave-start {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.dropdown-leave-end {
    opacity: 0;
    transform: translateY(-4px) scale(0.97);
}

/* ── Cards ────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--border-light);
}

/* ── Stat Cards ───────────────────────────────────────── */
.stat-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.primary {
    background: rgba(139, 0, 0, 0.1);
    color: var(--primary);
}

.stat-icon.accent {
    background: rgba(255, 215, 0, 0.15);
    color: #B8860B;
}

.stat-icon.success {
    background: var(--success-bg);
    color: var(--success);
}

.stat-icon.info {
    background: var(--info-bg);
    color: var(--info);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Tables ───────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 14px 16px;
    /* Uvećan padding za bolju čitljivost */
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

tbody tr:hover {
    background: rgba(139, 0, 0, 0.02);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ── Badges ───────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-primary {
    background: rgba(139, 0, 0, 0.1);
    color: var(--primary);
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    line-height: 1.4;
}

.btn:active {
    transform: scale(0.97);
}

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

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

.btn-secondary {
    background: var(--border-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-accent {
    background: var(--accent);
    color: #333;
}

.btn-accent:hover {
    background: #E6C200;
}

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

.btn-success:hover {
    background: #1B5E20;
    color: #fff;
}

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

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

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

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius);
}

/* ── Forms ────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    background: #f9fafb;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%236B7280'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

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

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-top: 24px;
}

.form-help {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Alerts ───────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border-left: 3px solid var(--success);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-left: 3px solid var(--warning);
}

.alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-left: 3px solid var(--danger);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
    border-left: 3px solid var(--info);
}

/* ── Page Header ──────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ── Empty State ──────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* ── Grid helpers ─────────────────────────────────────── */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

/* ── Utility ──────────────────────────────────────────── */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-secondary);
}

.text-primary {
    color: var(--primary);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-sm {
    font-size: 12px;
}

.fw-500 {
    font-weight: 500;
}

.fw-600 {
    font-weight: 600;
}

.fw-700 {
    font-weight: 700;
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.gap-1 {
    gap: 8px;
}

.gap-2 {
    gap: 16px;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .grid-4,
    .grid-5 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {

    .grid-2,
    .grid-3,
    .grid-4,
    .grid-5 {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

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

    /* Mobilne tablice */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -20px;
        padding: 0 20px;
    }

    table {
        min-width: 600px;
    }

    thead th,
    tbody td {
        padding: 8px 10px;
        font-size: 12px;
    }

    /* Sakrivanje manje bitnih stupaca na mobilnim */
    .hide-mobile {
        display: none;
    }

    .stat-value {
        font-size: 18px;
    }

    .stat-card {
        padding: 12px;
        gap: 10px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .page-content {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .stat-value {
        font-size: 16px;
    }

    .badge {
        font-size: 10px;
        padding: 2px 6px;
    }

    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* ── Skeleton Loading ─────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ── Slide-Over Drawer ────────────────────────────────── */
.slide-over-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1040;
}

.slide-over-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 500px;
    background: #fff;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-over-panel.open {
    transform: translateX(0);
}

.slide-over-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slide-over-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}