/* ================================================================
   JKZM Admin — Responsive (tablet + mobile)
   ----------------------------------------------------------------
   Breakpointy:
     - >= 1280px : desktop (default)
     - 1024-1279 : kompakt desktop
     -  768-1023 : tablet (sidebar off-canvas, hamburger)
     -  480-767  : mobile
     -   < 480   : small mobile
   Doplnkove admin-cinematic.css bez zasahov.
   Sidebar toggle riesi inline JS v index.html (setAdminSidebar).
   ================================================================ */

/* ---------- Base: hamburger + overlay (visible only <=1024px) ---------- */

.admin-hamburger {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 110;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-hi, #d1d5db);
    background: #ffffff;
    color: var(--ink, #0f172a);
    border-radius: 10px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
    transition: background 0.2s ease, border-color 0.2s ease, opacity 0.25s ease, transform 0.25s ease;
}
.admin-hamburger:hover {
    border-color: var(--gold, #b8954e);
    background: var(--gold-soft, rgba(184, 149, 78, 0.1));
}
.admin-hamburger:focus-visible {
    outline: 2px solid var(--gold, #b8954e);
    outline-offset: 2px;
}
.admin-hamburger-icon {
    display: block;
    width: 20px;
    height: 14px;
    position: relative;
}
.admin-hamburger-icon span {
    display: block;
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.2s ease, top 0.25s ease;
}
.admin-hamburger-icon span:nth-child(1) { top: 0; }
.admin-hamburger-icon span:nth-child(2) { top: 6px; }
.admin-hamburger-icon span:nth-child(3) { top: 12px; }
.admin-hamburger.is-open .admin-hamburger-icon span:nth-child(1) {
    top: 6px;
    transform: rotate(45deg);
}
.admin-hamburger.is-open .admin-hamburger-icon span:nth-child(2) {
    opacity: 0;
}
.admin-hamburger.is-open .admin-hamburger-icon span:nth-child(3) {
    top: 6px;
    transform: rotate(-45deg);
}
/* Keď je sidebar otvorený, hamburger sa skryje (sidebar prekryva)
   — zatváranie cez overlay-tap, ESC alebo swipe. */
.admin-hamburger.is-open {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

.admin-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 99;
}
.admin-sidebar-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* Prevent body scroll when sidebar open on mobile */
body.admin-sidebar-open {
    overflow: hidden;
}

/* ================================================================
   Breakpoint: kompakt desktop (1024-1279)
   ================================================================ */

@media (max-width: 1279px) {
    .main {
        padding: 1.5rem 1.75rem !important;
    }
    .form-row {
        gap: 0.85rem !important;
    }
}

/* ================================================================
   Breakpoint: tablet (<= 1023)  — sidebar off-canvas + hamburger
   ================================================================ */

@media (max-width: 1023px) {
    /* Hamburger + overlay active */
    .admin-hamburger {
        display: inline-flex;
    }

    /* Sidebar slide in from left */
    .sidebar {
        width: min(320px, 85vw) !important;
        max-width: 85vw;
        padding: 1.25rem !important;
        z-index: 105 !important;
    }
    .sidebar.open {
        box-shadow: 12px 0 40px rgba(15, 23, 42, 0.35);
    }

    /* Main full width, with top padding for hamburger */
    .main {
        margin-left: 0 !important;
        padding: 4.5rem 1.5rem 2rem !important;
        min-width: 0;
    }

    /* Sections should not overflow horizontally */
    .section {
        min-width: 0;
    }

    /* Header: stack action row under title */
    .header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.9rem;
        margin-bottom: 1.25rem !important;
    }
    .header h1 {
        font-size: 1.4rem !important;
        line-height: 1.25;
    }
    .header-actions {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.6rem !important;
        align-items: center;
    }
    .header-actions > * {
        flex-shrink: 0;
    }

    /* Search box expands */
    .search-box {
        flex: 1 1 180px;
        min-width: 160px;
    }
    .search-box input {
        width: 100% !important;
    }

    /* Form row: 2→1 col on tablet? Keep 2 col on tablet, 1 col on mobile */
    .form-row {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Card spacing */
    .card-header {
        padding: 0.85rem 1rem !important;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .card-body {
        padding: 1rem !important;
    }

    /* Tables — horizontal scroll inside card-body */
    .card-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .card-body > .table,
    .card-body > table.table {
        min-width: 680px;
    }

    /* Modals: near-full width, scroll body */
    .modal {
        padding: 0.75rem !important;
    }
    .modal-content {
        max-width: 100% !important;
        width: 100% !important;
        max-height: calc(100vh - 1.5rem) !important;
    }
    .modal-header {
        padding: 1rem 1.1rem !important;
    }
    .modal-header h3,
    .modal-header h2 {
        font-size: 1.05rem !important;
        line-height: 1.3;
    }
    .modal-body {
        padding: 1rem 1.1rem !important;
    }
    .modal-footer {
        padding: 0.85rem 1.1rem !important;
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }
    .modal-footer .btn {
        flex: 1 1 auto;
        min-width: 120px;
        justify-content: center;
    }

    /* Tabs: horizontal scroll to prevent wrap */
    .tabs,
    .tab-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        flex-wrap: nowrap !important;
        scrollbar-width: thin;
    }
    .tabs::-webkit-scrollbar,
    .tab-bar::-webkit-scrollbar {
        height: 4px;
    }
    .tab {
        padding: 0.7rem 0.9rem !important;
        font-size: 0.84rem !important;
        flex-shrink: 0;
    }

    /* Dashboard 2-col grid → 1 col on tablet */
    .section#dashboard > div[style*="grid-template-columns:1fr 1fr"],
    .section#dashboard > div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Stats grid tighter */
    .stats-grid {
        gap: 1rem !important;
    }
    .stat-card {
        padding: 1rem !important;
    }
    .stat-card .value {
        font-size: 1.6rem !important;
    }

    /* Quick actions */
    .quick-actions {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
        gap: 0.75rem !important;
    }
    .quick-action {
        padding: 0.9rem !important;
    }

    /* Toast — don't hog bottom-right on small screens */
    .toast {
        right: 1rem !important;
        bottom: 1rem !important;
        left: 1rem;
        max-width: calc(100vw - 2rem);
    }
}

/* ================================================================
   Breakpoint: mobile (<= 767)
   ================================================================ */

@media (max-width: 767px) {
    .main {
        padding: 4.25rem 1rem 1.5rem !important;
    }

    .header h1 {
        font-size: 1.2rem !important;
    }

    /* Form row — 1 col on mobile */
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* Header actions: full-width buttons stack */
    .header-actions {
        gap: 0.5rem !important;
    }
    .header-actions .btn {
        flex: 1 1 calc(50% - 0.25rem);
        justify-content: center;
    }
    .header-actions .btn-primary {
        flex: 1 1 100%;
        order: -1;
    }
    .header-actions .form-control[style*="width:auto"],
    .header-actions input.form-control,
    .header-actions select.form-control {
        flex: 1 1 100%;
        width: 100% !important;
        min-width: 0;
    }

    /* Stats grid: 2 columns on mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.65rem !important;
    }
    .stat-card {
        padding: 0.85rem !important;
    }
    .stat-card .value {
        font-size: 1.35rem !important;
    }
    .stat-card .label {
        font-size: 0.72rem !important;
    }
    .stat-card .icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.1rem !important;
        margin-bottom: 0.5rem !important;
    }

    /* Quick actions 2 cols */
    .quick-actions {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Tables — table-layout on mobile: wrap card-body, keep min-width so user scrolls */
    .card-body > .table,
    .card-body > table.table {
        min-width: 560px;
        font-size: 0.82rem !important;
    }
    .table th,
    .table td {
        padding: 0.6rem 0.65rem !important;
    }

    /* Modal full-width */
    .modal {
        padding: 0 !important;
        align-items: flex-end !important;
    }
    .modal-content {
        max-width: 100% !important;
        width: 100% !important;
        max-height: 100vh !important;
        height: 100vh;
        border-radius: 0 !important;
        display: flex;
        flex-direction: column;
    }
    .modal-body {
        flex: 1 1 auto;
        overflow-y: auto;
    }
    .modal-footer {
        flex-direction: column-reverse;
    }
    .modal-footer .btn {
        width: 100%;
        flex: 0 0 auto;
    }

    /* Horse card: stack image above content */
    .horse-card {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }
    .horse-card img {
        width: 100% !important;
        height: 180px !important;
    }

    /* Cards tighter */
    .card {
        margin-bottom: 1rem !important;
    }
    .card-header h3 {
        font-size: 0.95rem !important;
    }

    /* Calendar week grid — 1 col */
    .calendar-week {
        grid-template-columns: 1fr !important;
    }
    .calendar-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem;
    }

    /* Analytics/web-status inline grids */
    [id="analyticsGrid"],
    [id="webStatusGrid"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.6rem !important;
    }

    /* Input width overrides for inline filters (e.g. width:auto, width:200px) */
    .header-actions input[style*="width:200px"],
    .header-actions select[style*="width:200px"],
    .header-actions input[style*="width:180px"],
    .header-actions select[style*="width:180px"],
    .header-actions input[style*="width:150px"],
    .header-actions select[style*="width:150px"] {
        width: 100% !important;
    }

    /* Fieldset padding */
    fieldset,
    .fieldset {
        padding: 0.85rem !important;
    }

    /* Vet timeline */
    .vet-timeline {
        padding-left: 1.4rem;
    }

    /* Sidebar footer links smaller */
    .sidebar .nav-item {
        font-size: 0.88rem !important;
        padding: 0.55rem 0.85rem !important;
    }
}

/* ================================================================
   Login page — responsive
   ================================================================ */

@media (max-width: 767px) {
    .login-page {
        padding: 1rem !important;
    }
    .login-box {
        padding: 1.75rem 1.25rem !important;
        max-width: 100% !important;
    }
    .login-box h2 {
        font-size: 1.25rem !important;
        margin-bottom: 1.25rem !important;
    }
    .login-box img {
        height: 64px !important;
        margin-bottom: 1rem !important;
    }
}

/* ================================================================
   Breakpoint: small mobile (<= 479)
   ================================================================ */

@media (max-width: 479px) {
    .main {
        padding: 4rem 0.75rem 1.25rem !important;
    }
    .header h1 {
        font-size: 1.1rem !important;
    }

    /* Stats: 1 col */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    /* Quick actions: 1 col */
    .quick-actions {
        grid-template-columns: 1fr !important;
    }

    /* Analytics grids 1 col */
    [id="analyticsGrid"],
    [id="webStatusGrid"] {
        grid-template-columns: 1fr !important;
    }

    /* Hamburger smaller */
    .admin-hamburger {
        top: 10px;
        left: 10px;
        width: 40px;
        height: 40px;
    }

    /* Tighter tables */
    .card-body > .table,
    .card-body > table.table {
        min-width: 480px;
        font-size: 0.78rem !important;
    }

    /* Toast full-width bottom */
    .toast {
        font-size: 0.82rem !important;
        padding: 0.7rem 0.9rem !important;
    }
}

/* ================================================================
   Desktop overrides: hide hamburger safely
   ================================================================ */

@media (min-width: 1024px) {
    .admin-hamburger,
    .admin-sidebar-overlay {
        display: none !important;
    }
    body.admin-sidebar-open {
        overflow: auto;
    }
}
