/**
 * Kokpit Dewelopera - Styles
 * Works for both admin and frontend
 */

/* =========================================
   1. RESPONSIVE TABLE CONTAINER
   ========================================= */

.kokpit-responsive-table,
.kokpit-table-container {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    border: 1px solid #ddd;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border-radius: 4px;
}

/* =========================================
   2. STYLED TABLE
   ========================================= */

.kokpit-styled-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    min-width: 500px;
    font-size: 14px;
    line-height: 1.5;
}

.kokpit-styled-table th,
.kokpit-styled-table td {
    padding: 12px 15px;
    text-align: left;
    border: 1px solid #ddd;
    color: #333;
    vertical-align: middle;
}

.kokpit-styled-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    border-bottom: 2px solid #ccc;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
}

.kokpit-styled-table tbody tr:nth-child(even) {
    background-color: #fafafa;
}

.kokpit-styled-table tbody tr:hover {
    background-color: #f5f5f5;
}

/* =========================================
   3. HISTORY BLOCK
   ========================================= */

.kokpit-history-block {
    background: #fff;
    border: 1px solid #ddd;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.kokpit-file-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.kokpit-file-list li {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.kokpit-file-list li:last-child {
    border-bottom: none;
}

.kokpit-file-list .file-info {
    font-size: 14px;
    color: #333;
}

.kokpit-file-list .file-info small {
    color: #888;
}

.kokpit-empty-notice {
    color: #666;
    font-style: italic;
    padding: 20px 0;
    text-align: center;
}

/* =========================================
   4. MODAL
   ========================================= */

.kokpit-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 999999;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.kokpit-modal-wrap {
    background: #fff;
    width: 95%;
    max-width: 1200px;
    max-height: 90vh;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
}

.kokpit-modal-header {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.kokpit-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.kokpit-close-modal {
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    color: #666;
    transition: color 0.2s;
    padding: 0 5px;
}

.kokpit-close-modal:hover {
    color: #000;
}

.kokpit-modal-body {
    flex: 1;
    overflow: auto;
    padding: 0;
    background: #fff;
    min-height: 200px;
    max-height: calc(90vh - 140px);
}

.kokpit-modal-body .kokpit-table-container,
.kokpit-modal-body .kokpit-responsive-table {
    border: none;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

.kokpit-modal-footer {
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
    text-align: right;
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* =========================================
   5. BUTTONS
   ========================================= */

.kokpit-history-block .button,
.kokpit-modal .button {
    display: inline-block;
    padding: 6px 12px;
    font-size: 13px;
    line-height: 1.5;
    text-decoration: none;
    border-radius: 3px;
    cursor: pointer;
    border: 1px solid #ccc;
    background: #f7f7f7;
    color: #333;
    transition: all 0.2s;
}

.kokpit-history-block .button:hover,
.kokpit-modal .button:hover {
    background: #fafafa;
    border-color: #999;
}

.kokpit-modal .button-primary {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
}

.kokpit-modal .button-primary:hover {
    background: #005a87;
    border-color: #005a87;
    color: #fff;
}

/* =========================================
   6. NOTICE STYLES
   ========================================= */

.kokpit-notice {
    padding: 15px 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    text-align: center;
}

/* =========================================
   7. EDITOR PREVIEW STYLES
   ========================================= */

.kokpit-block-preview {
    min-height: 100px;
}

.kokpit-block-preview .kokpit-responsive-table,
.kokpit-block-preview .kokpit-history-block {
    pointer-events: none;
}

/* =========================================
   8. ADMIN SPECIFIC STYLES
   ========================================= */

/* Editor table styles */
.kokpit-editor-container {
    background: #fff;
    border: 1px solid #ccc;
    padding: 10px;
    margin-top: 10px;
}

/* Admin table editor */
.kokpit-styled-table [contenteditable="true"] {
    min-width: 80px;
    outline: none;
    cursor: text;
}

.kokpit-styled-table [contenteditable="true"]:focus {
    background: #fff8e1;
    box-shadow: inset 0 0 0 2px #ffc107;
}

/* Column/row actions */
.col-header {
    position: relative;
}

.col-actions {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
}

.del-col-btn,
.del-row-btn {
    background: #dc3545;
    color: #fff;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}

.del-col-btn:hover,
.del-row-btn:hover {
    background: #c82333;
}

.gutter-header,
.gutter-row {
    width: 30px;
    text-align: center;
    background: #f8f9fa;
}

/* =========================================
   9. RESPONSIVE ADJUSTMENTS
   ========================================= */

@media (max-width: 768px) {
    .kokpit-modal-wrap {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .kokpit-modal-body {
        max-height: calc(100vh - 140px);
    }

    .kokpit-file-list li {
        flex-direction: column;
        align-items: flex-start;
    }

    .kokpit-file-list li .button {
        margin-top: 10px;
    }

    .kokpit-modal-footer {
        flex-direction: column;
    }

    .kokpit-modal-footer .button {
        width: 100%;
        text-align: center;
    }
}

/* =========================================
   10. LOADING STATE
   ========================================= */

.kokpit-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #666;
}

.kokpit-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: #007cba;
    border-radius: 50%;
    margin-right: 10px;
    animation: kokpit-spin 0.8s linear infinite;
}

@keyframes kokpit-spin {
    to {
        transform: rotate(360deg);
    }
}

/* =========================================
   11. PRINT STYLES
   ========================================= */

@media print {
    .kokpit-modal {
        display: none !important;
    }

    .kokpit-history-block .button {
        display: none;
    }

    .kokpit-styled-table {
        font-size: 12px;
    }

    .kokpit-styled-table th,
    .kokpit-styled-table td {
        padding: 8px;
    }
}
