/* ═══════════════════════════════════════════
   Admin Panel & Mobile Responsive Styles (v2.0)
   ═══════════════════════════════════════════ */

/* ─── Helper Classes ─── */
.hidden { display: none !important; }
.full-width { width: 100%; }
.mb-24 { margin-bottom: 24px; }
.file-hidden { display: none; }
.empty-cell { text-align: center; padding: 20px; color: var(--text-dim); }

/* ─── Admin Panel ─── */
.admin-container { max-width: 1200px; margin: 2rem auto; }
.admin-title {
    color: var(--text-main);
    font-family: 'Amiri', serif;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2rem;
}
.admin-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
}
.admin-card-header { margin-top: 0; font-family: 'Amiri', serif; }
.db-status-wrap {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 16px;
    flex-wrap: wrap;
}
.db-status-ok {
    color: var(--green);
    font-weight: bold;
    font-family: 'Noto Sans Arabic', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.db-status-missing {
    color: var(--red);
    font-weight: bold;
    font-family: 'Noto Sans Arabic', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn-download {
    padding: 8px 16px;
    background: var(--accent-gold);
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    font-family: 'Noto Sans Arabic', sans-serif;
    transition: 0.2s;
}
.btn-download:hover { opacity: 0.85; }
.btn-upload-replace, .btn-upload-first {
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: bold;
    font-family: 'Noto Sans Arabic', sans-serif;
    transition: 0.2s;
}
.btn-upload-replace {
    background: #E2E8F0;
    color: var(--text-primary);
}
.btn-upload-first {
    background: var(--green);
    color: white;
}
.btn-upload-replace:hover, .btn-upload-first:hover { opacity: 0.85; }

.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}
.logs-title { margin: 0; font-family: 'Amiri', serif; }
.table-responsive { overflow-x: auto; }
.rtl-table { text-align: right; }

/* ─── Buttons ─── */
.btn-primary {
    background: var(--green);
    color: white;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    font-family: 'Noto Sans Arabic', sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    transition: 0.2s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-danger {
    background: var(--red);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-family: 'Noto Sans Arabic', sans-serif;
}
.btn-secondary {
    background: #e2e8f0;
    color: var(--text-primary);
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Noto Sans Arabic', sans-serif;
}
.btn-icon {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
}

/* ─── Manage Header ─── */
.manage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.manage-header-title {
    color: var(--text-primary);
    font-family: 'Amiri', serif;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}
.manage-header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}
.search-input-wrapper { position: relative; }
.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}
.search-input {
    padding: 10px 40px 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: 'Noto Sans Arabic', sans-serif;
    width: 250px;
    background: white;
}

/* ─── Modal ─── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15,23,42,0.5);
    z-index: 9999;
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 600px;
    padding: 2rem;
    transform: scale(0.95);
    transition: transform 0.2s;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.modal-title {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.4rem;
}
.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}
.form-input {
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-family: 'Noto Sans Arabic', sans-serif;
}
.form-checkbox-wrap {
    display: flex;
    gap: 2rem;
    align-items: center;
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    flex-wrap: wrap;
}
.form-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}
.form-checkbox { width: 18px; height: 18px; }
.harakaat-box {
    display: none;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.harakaat-btn-group { display: flex; gap: 6px; }
.hk-btn {
    width: 36px; height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
    font-family: 'Noto Sans Arabic', sans-serif;
    font-weight: bold;
    transition: 0.2s;
}
.hk-btn.active {
    background: var(--green) !important;
    color: white !important;
    border-color: var(--green) !important;
    box-shadow: var(--shadow-sm);
}
.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}
.modal-actions {
    display: flex;
    gap: 10px;
    margin-right: auto;
}
.hidden-delete-btn { display: none; }

/* ─── Log Header ─── */
.log-controls {
    margin-bottom: 0;
    justify-content: space-between;
}
.log-header {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-refresh {
    padding: 8px 16px;
    background: var(--bg-card-alt);
    border-radius: 6px;
    border: 1px solid var(--border);
}

/* ─── Table Cell Utility ─── */
.rule-category { font-weight: 600; color: var(--text-dim); }
.rule-name { font-weight: 700; color: var(--text-primary); font-size: 1.1rem; }
.rule-role-badge {
    font-size: 0.85rem;
    padding: 4px 8px;
    background: #f1f5f9;
    border-radius: 4px;
    color: var(--text-dim);
}
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-dim { color: var(--text-dim); }
.harakaat-badge {
    font-size: 0.85rem;
    padding: 4px 8px;
    background: #e0f2fe;
    color: #0284c7;
    border-radius: 4px;
}
.edit-btn {
    padding: 6px 12px;
    background: var(--accent-gold);
    color: white;
    border: none;
    border-radius: 6px;
    font-family: 'Noto Sans Arabic', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: 0.2s;
}
.edit-btn:hover { opacity: 0.85; }

/* ─── Admin Log Badges ─── */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}
.badge-add { background: #D1FAE5; color: #059669; }
.badge-update { background: #FEF3C7; color: #D97706; }
.badge-delete { background: #FEE2E2; color: #DC2626; }
.badge-upload { background: #E0F2FE; color: #0284C7; }
.ltr-cell { direction: ltr; text-align: right; }
.log-detail {
    margin: 0;
    font-family: monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    text-align: left;
    direction: ltr;
    background: #F8FAFC;
    padding: 4px;
    border-radius: 4px;
}

/* ═══════════════════════════════════════════
   MOBILE RESPONSIVE STYLES
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Navbar */
    .navbar {
        flex-direction: column;
        height: auto;
        padding: 12px 16px;
        gap: 8px;
    }
    .nav-tabs {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tab {
        padding: 10px 14px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    /* Container */
    .container {
        padding: 0 12px !important;
        margin: 1rem auto !important;
    }
    .admin-container {
        margin: 1rem auto !important;
        padding: 0 12px;
    }

    /* Controls */
    .controls {
        flex-direction: column;
        gap: 12px;
        padding: 16px !important;
    }
    .control-group {
        width: 100%;
    }
    .control-group select {
        width: 100%;
    }
    .state-toggle {
        flex-wrap: wrap;
    }

    /* Review Progress */
    .review-progress {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 16px;
    }

    /* Ayah Card */
    .ayah-card {
        margin: 12px;
    }
    .ayah-text {
        font-size: 1.4rem !important;
    }

    /* Details Panel */
    .details-panel.open {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        max-height: 70vh;
        overflow-y: auto;
        z-index: 100;
        border-radius: 16px 16px 0 0;
    }

    /* Stats */
    .stats-bar {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Legend */
    .legend-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Manage Header */
    .manage-header {
        flex-direction: column;
        align-items: stretch;
    }
    .manage-header-actions {
        flex-direction: column;
    }
    .search-input {
        width: 100%;
    }

    /* Tables */
    .log-table-wrap, .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .rules-table, .log-table {
        min-width: 600px;
    }

    /* Admin Panel */
    .admin-title {
        font-size: 1.3rem;
    }
    .admin-card {
        padding: 14px;
    }
    .db-status-wrap {
        flex-direction: column;
        align-items: stretch;
    }
    .btn-download, .btn-upload-replace, .btn-upload-first {
        text-align: center;
        display: block;
    }
    .logs-header {
        flex-direction: column;
        align-items: stretch;
    }

    /* Modal */
    .modal-content {
        width: 95%;
        padding: 1.2rem;
        max-height: 85vh;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .modal-footer {
        flex-direction: column;
        gap: 10px;
    }
    .modal-actions {
        width: 100%;
        margin: 0;
    }
    .modal-actions button {
        flex: 1;
    }

    /* Log Controls */
    .log-controls {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .nav-brand {
        font-size: 1.2rem;
    }
    .nav-tab {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
    .ayah-text {
        font-size: 1.2rem !important;
    }
    .manage-header-title {
        font-size: 1.3rem;
    }
}
