/* ========================================
   RESPONSIVE ADJUSTMENTS - Mobile First
   ======================================== */

/* ========================================
   TABLET & MOBILE — Max 1024px
   Panel visibility is controlled by JS (main.js switchMobilePanel)
   ======================================== */
@media (max-width: 1024px) {

    /* Reset panel constraints */
    #panel-segments,
    #panel-library,
    #panel-clock {
        max-width: none;
        min-width: 0;
        width: 100%;
        flex: 1;
        /* Match remaining space */
        min-height: 0;
        overflow: hidden;
    }

    /* Main layout - column, no scroll (JS handles panel switching) */
    #clock-view {
        flex-direction: column;
        overflow: hidden;
    }

    /* Force hardware acceleration and touch scrolling optimizations on scrolling containers */
    #active-segments-list,
    #templates-list-container,
    .rundown-table-wrapper {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        will-change: transform, scroll-position;
        backface-visibility: hidden;
        transform: translateZ(0);
        /* Force GPU layer */
    }

    /* Header compact */
    #main-app-content>header {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* Rundown Specifics */
    .spreadsheet-container {
        max-height: calc(100vh - 180px);
    }

    .spreadsheet th,
    .spreadsheet td {
        padding: 6px 8px;
        font-size: 13px;
    }

    .spreadsheet .row-header {
        width: 24px;
        min-width: 24px;
        font-size: 10px;
    }
}

/* ========================================
   MOBILE — Max 768px
   ======================================== */
@media (max-width: 768px) {

    /* Clock container responsive */
    #clock-container {
        width: 100% !important;
        max-width: 420px;
    }

    #clock-pie-view {
        padding: 0.5rem !important;
    }

    /* Segment Cards - touch friendly */
    .segment-card {
        padding: 0.625rem;
        gap: 0.5rem;
    }

    .segment-card .segment-time {
        width: 2.5rem;
        font-size: 0.65rem;
    }

    .segment-card .segment-icon {
        width: 2rem;
        height: 2rem;
    }

    /* Always show controls on mobile (no hover) */
    .segment-card .duration-controls {
        opacity: 1;
    }

    .segment-card .delete-btn {
        opacity: 1;
    }

    /* Library Items - always show actions */
    .library-item .more-btn {
        opacity: 1;
    }

    .library-folder .folder-add-btn {
        opacity: 1;
    }

    /* ========================================
       RUNDOWN MOBILE CARD LAYOUT
       ======================================== */
    .rundown-table-wrapper {
        display: none;
    }

    .rundown-controls {
        padding: 1rem;
        gap: 0.75rem;
    }

    .rundown-header {
        padding: 1.25rem 1rem;
    }

    .rundown-header h2 {
        font-size: 1.375rem;
    }

    .rundown-cards {
        display: flex;
        flex-direction: column;
        gap: 0.875rem;
        padding: 1rem;
    }

    .rundown-card {
        background: rgba(30, 41, 59, 0.8);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-radius: 1rem;
        padding: 1.25rem;
        border-left: 4px solid var(--rundown-accent);
        transition: var(--rundown-transition);
        box-shadow:
            0 4px 15px -3px rgba(0, 0, 0, 0.2),
            0 0 0 1px rgba(255, 255, 255, 0.05);
        position: relative;
        overflow: hidden;
    }

    .rundown-card::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 1px;
        background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.3), transparent);
    }

    .rundown-card:active {
        transform: scale(0.98);
        box-shadow:
            0 2px 10px -3px rgba(0, 0, 0, 0.3),
            0 0 0 2px rgba(99, 102, 241, 0.3);
    }

    .rundown-card .card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 0.75rem;
    }

    .rundown-card .card-name {
        font-size: 1.0625rem;
        font-weight: 700;
        color: var(--rundown-text);
    }

    .rundown-card .card-type {
        font-size: 0.6875rem;
        font-weight: 600;
        padding: 0.3125rem 0.625rem;
        border-radius: 9999px;
        background: rgba(99, 102, 241, 0.2);
        color: var(--rundown-accent-light);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .rundown-card .text-gray-400 {
        color: var(--rundown-text-muted);
        line-height: 1.5;
    }

    .rundown-card .card-times {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--glass-border);
    }

    .rundown-card .time-item {
        text-align: center;
        padding: 0.5rem;
        background: rgba(15, 23, 42, 0.5);
        border-radius: 0.625rem;
    }

    .rundown-card .time-label {
        font-size: 0.625rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        color: var(--rundown-text-muted);
        margin-bottom: 0.25rem;
    }

    .rundown-card .time-value {
        font-family: 'JetBrains Mono', ui-monospace, monospace;
        font-size: 0.9375rem;
        font-weight: 700;
        color: var(--rundown-accent-light);
    }

    .rundown-card .card-actions {
        display: flex;
        justify-content: flex-end;
        gap: 0.625rem;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--glass-border);
    }

    .rundown-card .row-action-btn {
        width: 2.5rem;
        height: 2.5rem;
        background: rgba(30, 41, 59, 0.8);
        border-radius: 0.625rem;
    }

    /* Rundown panel header compact */
    #panel-rundown>header {
        height: auto;
        min-height: 56px;
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    #panel-rundown>header h1 {
        font-size: 1rem;
    }
}

/* ========================================
   SMALL MOBILE — Max 400px
   ======================================== */
@media (max-width: 400px) {
    #clock-container {
        max-width: 300px;
    }
}

/* ========================================
   DESKTOP ONLY — Min 1025px
   ======================================== */
@media (min-width: 1025px) {
    .rundown-cards {
        display: none;
    }
}

/* Desktop Only - Hide Cards */
@media (min-width: 769px) {
    .rundown-cards {
        display: none;
    }
}