/* ============================================
   RESPONZIVITA - MAPA SKŘÍNĚK
   Verze: 6.0
   ============================================ */

/* === TABLET (max-width: 900px) === */
@media (max-width: 900px) {
    /* --- LAYOUT --- */
    .top-panel {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .archive-controls-inline {
        grid-template-columns: 1fr;
    }

    /* --- HLAVIČKA --- */
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-md);
    }

    .header h1 {
        font-size: 1.5em;
    }

    .header-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    /* --- TABULKY --- */
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-xs);
    }

    table {
        font-size: 0.9em;
    }

    th, td {
        padding: var(--spacing-xs);
    }

    .cell-content {
        font-size: 12px;
    }

    /* --- OVLÁDACÍ PANEL --- */
    .control-panel {
        padding: var(--spacing-lg);
    }

    .target-option {
        display: block;
        margin-bottom: var(--spacing-md);
    }

    .other-table-fields-hidden {
        margin-left: 0;
        margin-top: var(--spacing-md);
    }

    .other-table-fields-hidden label {
        display: block;
        margin-right: 0;
        margin-bottom: var(--spacing-sm);
    }

    /* --- SCHRÁNKA --- */
    .clipboard-panel {
        height: auto;
    }

    .clipboard-list {
        max-height: 300px;
    }

    /* --- ARCHIVACE --- */
    .archive-column-inline {
        padding-bottom: var(--spacing-lg);
        border-bottom: 1px solid var(--border-color);
    }

    .archive-column-inline:last-child {
        padding-bottom: 0;
        border-bottom: none;
    }

    .archive-list {
        max-height: 250px;
    }

    /* --- GRID POMOCNÉ --- */
    .grid-2-col,
    .grid-3-col {
        grid-template-columns: 1fr;
    }
}

/* === MOBIL (max-width: 480px) === */
@media (max-width: 480px) {
    /* --- ZÁKLADNÍ --- */
    body {
        margin: 0;
        padding: 0;
    }

    .container {
        padding: var(--spacing-md);
    }

    /* --- HLAVIČKA --- */
    .header {
        padding-bottom: var(--spacing-md);
    }

    .header h1 {
        font-size: 1.3em;
    }

    .header h1 a {
        font-size: 1em;
    }

    .header-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-xs);
    }

    .reset-btn {
        width: 100%;
        text-align: center;
        margin-top: var(--spacing-sm);
    }

    /* --- ZPRÁVY --- */
    .message {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-small);
        flex-wrap: wrap;
    }

    .message::before {
        font-size: 1em;
    }

    .conflict-warning {
        padding: var(--spacing-sm);
    }

    /* --- OVLÁDACÍ PANEL --- */
    .control-panel {
        padding: var(--spacing-md);
    }

    .control-panel h2 {
        font-size: 1.2em;
    }

    .edit-form {
        padding: var(--spacing-md);
    }

    .edit-form h3 {
        font-size: 1em;
    }

    .edit-form input[type="text"],
    .edit-form input[type="number"],
    .edit-form textarea {
        font-size: 16px; /* Prevence zoomu na iOS */
    }

    .move-options,
    .target-selection {
        padding: var(--spacing-sm);
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions button,
    .form-actions a {
        width: 100%;
    }

    /* --- GRID SETTINGS --- */
    .grid-settings h3 {
        font-size: 1em;
    }

    .grid-control-group {
        flex-direction: column;
        align-items: flex-start;
    }

    .grid-control-group strong {
        margin-bottom: var(--spacing-xs);
    }

    .grid-control-group a {
        margin-right: var(--spacing-xs);
        margin-bottom: var(--spacing-xs);
    }

    /* --- SCHRÁNKA --- */
    .clipboard-panel {
        padding: var(--spacing-md);
    }

    .clipboard-panel h2 {
        font-size: 1.2em;
    }

    .clipboard-add-form {
        flex-direction: column;
    }

    .clipboard-add-form input[type="text"] {
        font-size: 16px; /* Prevence zoomu na iOS */
    }

    .clipboard-add-form button {
        width: 100%;
        min-width: auto;
    }

    .clipboard-item {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }

    .clip-text {
        width: 100%;
        margin-right: 0;
        margin-bottom: var(--spacing-xs);
    }

    .clip-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .clip-actions button {
        flex: 1;
        min-width: auto;
    }

    /* --- ARCHIVACE --- */
    .archive-section-inline {
        margin-top: var(--spacing-lg);
        padding-top: var(--spacing-lg);
    }

    .archive-summary-inline {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-small);
    }

    .archive-controls-inline {
        padding: var(--spacing-md);
    }

    .archive-column-inline h4 {
        font-size: 1em;
    }

    .archive-item {
        padding: var(--spacing-sm);
    }

    .archive-actions {
        flex-direction: column;
    }

    .archive-actions button {
        width: 100%;
    }

    .archive-filename {
        font-size: var(--font-size-small);
    }

    /* --- TABULKY --- */
    th {
        font-size: 11px;
        height: 30px;
        padding: var(--spacing-xs);
    }

    td {
        height: auto;
        min-height: 60px;
        padding: var(--spacing-xs);
    }

    .cell-content {
        font-size: 11px;
        white-space: normal; /* Na mobilu necháme text zalomit */
        text-overflow: clip;
        overflow: visible;
    }

    /* --- FORMULÁŘE --- */
    input[type="text"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px; /* Prevence zoomu na iOS */
    }

    /* --- TLAČÍTKA --- */
    button,
    .btn {
        width: 100%;
        margin-bottom: var(--spacing-xs);
    }

    .btn-sm {
        width: auto; /* Zachovat malá tlačítka v seznamu */
    }

    .print-btn {
        padding: var(--spacing-md);
    }

    /* --- POMOCNÉ TŘÍDY --- */
    .m-0, .m-1, .m-2, .m-3, .m-4, .m-5 {
        margin: var(--spacing-sm);
    }

    .p-0, .p-1, .p-2, .p-3, .p-4, .p-5 {
        padding: var(--spacing-sm);
    }
}

/* === VERY SMALL (max-width: 320px) === */
@media (max-width: 320px) {
    .container {
        padding: var(--spacing-sm);
    }

    .header h1 {
        font-size: 1.1em;
    }

    th {
        font-size: 10px;
    }

    .cell-content {
        font-size: 10px;
    }

    .grid-control-group a {
        padding: 2px 4px;
        font-size: 11px;
    }
}

/* === LANDSCAPE MODE (volitelné) === */
@media (max-width: 900px) and (orientation: landscape) {
    .top-panel {
        grid-template-columns: 1fr 1fr;
    }

    .clipboard-list {
        max-height: 200px;
    }

    .archive-list {
        max-height: 150px;
    }
}

/* === HIGH DPI DISPLAYS === */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Tenčí borders pro Retina displeje */
    th, td {
        border-width: 0.5px;
    }

    .archive-item,
    .clipboard-item,
    .history-item {
        border-width: 0.5px;
    }
}

/* === REDUCED MOTION (přístupnost) === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* === DARK MODE (volitelné - pro budoucnost) === */
@media (prefers-color-scheme: dark) {
    /*
     * Pro budoucí implementaci tmavého režimu
     * Stačí přepsat proměnné v :root
     */
    /*
    :root {
        --bg-color: #1a1a1a;
        --text-color: #f0f0f0;
        --border-color: #444;
        --primary-color: #6ab0f3;
        ...
    }
    */
}