/**
 * WordPress Module Styles - Compact List Format
 * Reduced button sizes and clean design
 */

/* ========== Container & Layout ========== */
.wp-module-container {
    width: 100%;
    max-width: 100%;
    padding: 1rem;
}

/* ========== Header ========== */
.wp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #8352F1 0%, #6F3DDB 100%);
    border-radius: 8px;
    color: white;
}

.wp-header-left {
    flex: 1;
}

.wp-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.wp-title i {
    font-size: 1.75rem;
}

.wp-subtitle {
    font-size: 0.875rem;
    margin: 0;
    opacity: 0.9;
}

.wp-header-right {
    display: flex;
    gap: 0.5rem;
}

/* ========== Compact Buttons ========== */
.wp-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.813rem;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.wp-btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.wp-btn-primary {
    background: #8352F1;
    color: white;
}

.wp-btn-primary:hover {
    background: #6F3DDB;
}

.wp-btn-secondary {
    background: #64748b;
    color: white;
}

.wp-btn-secondary:hover {
    background: #475569;
}

.wp-btn-success {
    background: #10b981;
    color: white;
}

.wp-btn-success:hover {
    background: #059669;
}

.wp-btn-warning {
    background: #f59e0b;
    color: white;
}

.wp-btn-warning:hover {
    background: #d97706;
}

.wp-btn-danger {
    background: #ef4444;
    color: white;
}

.wp-btn-danger:hover {
    background: #dc2626;
}

.wp-btn-info {
    background: #8352F1;
    color: white;
}

.wp-btn-info:hover {
    background: #8352F1;
}

.wp-btn-accent {
    background: #8352F1;
    color: white;
}

.wp-btn-accent:hover {
    background: #8352F1;
}

.wp-btn-clone {
    background: #06b6d4;
    color: white;
}

.wp-btn-clone:hover {
    background: #0891b2;
}

/* ========== Icon-Only Buttons (Very Compact) ========== */
.wp-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 0.75rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.wp-btn-icon:hover {
    background: #f1f5f9;
}

/* ========== List Container ========== */
.wp-list-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* ========== WordPress Sites Table ========== */
.wp-list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.wp-list-table thead {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

.wp-list-table th {
    padding: 0.75rem 0.875rem;
    text-align: left;
    font-weight: 600;
    color: #475569;
    font-size: 0.813rem;
    white-space: nowrap;
}

.wp-list-table th i {
    margin-right: 0.375rem;
    opacity: 0.7;
}

.wp-list-table tbody tr {
    border-bottom: 1px solid #e2e8f0;
    transition: background 0.15s ease;
}

.wp-list-table tbody tr:hover {
    background: #f8fafc;
}

.wp-list-table td {
    padding: 0.75rem 0.875rem;
    vertical-align: middle;
}

.wp-domain {
    font-weight: 500;
    color: #1e293b;
}

.wp-domain i {
    margin-right: 0.5rem;
    color: #8352F1;
}

.wp-path code {
    background: #f1f5f9;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #334155;
}

.wp-version-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: #EEE6FD;
    color: #5D2CC5;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.wp-status-active {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: #059669;
    font-weight: 500;
    font-size: 0.813rem;
}

.wp-status-active i {
    font-size: 0.875rem;
}

.wp-status-inactive {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: #dc2626;
    font-weight: 500;
    font-size: 0.813rem;
}

/* ========== Action Buttons Column ========== */
.wp-actions-col {
    width: 320px;
    text-align: center;
    white-space: nowrap;
}

.wp-action-buttons {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    flex-wrap: nowrap;
    align-items: center;
}

/* ========== Empty State ========== */
.wp-empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #64748b;
}

.wp-empty-state i {
    color: #cbd5e1;
    margin-bottom: 1rem;
}

.wp-empty-state h3 {
    margin: 0.5rem 0;
    color: #334155;
}

.wp-empty-state p {
    margin: 0;
    font-size: 0.875rem;
}

/* ========== Loading State ========== */
.wp-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: #64748b;
    font-size: 0.875rem;
}

.wp-loading i {
    font-size: 1.25rem;
}

/* ========== Modals ========== */
.wp-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.wp-modal.active {
    display: flex;
}

.wp-modal-dialog {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.wp-modal-lg {
    max-width: 800px;
}

.wp-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.wp-modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.wp-modal-close {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: #64748b;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.15s;
}

.wp-modal-close:hover {
    color: #1e293b;
}

.wp-modal-body {
    padding: 1.5rem;
}

.wp-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1.5rem;
    margin-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

/* ========== Form Elements ========== */
.wp-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.wp-form-group {
    display: flex;
    flex-direction: column;
}

.wp-form-group label {
    font-size: 0.813rem;
    font-weight: 500;
    color: #475569;
    margin-bottom: 0.375rem;
}

.wp-form-group input,
.wp-form-group select,
.wp-form-group textarea {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    transition: border-color 0.15s;
}

.wp-form-group input:focus,
.wp-form-group select:focus,
.wp-form-group textarea:focus {
    outline: none;
    border-color: #8352F1;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.wp-input-sm {
    padding: 0.375rem 0.625rem;
    font-size: 0.813rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
}

/* ========== Plugin/Theme Lists ========== */
.wp-plugin-actions,
.wp-theme-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.wp-plugin-list,
.wp-theme-list {
    max-height: 400px;
    overflow-y: auto;
}

.wp-plugin-table,
.wp-theme-table {
    width: 100%;
    font-size: 0.813rem;
}

.wp-plugin-table th,
.wp-theme-table th {
    background: #f8fafc;
    padding: 0.5rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
}

.wp-plugin-table td,
.wp-theme-table td {
    padding: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.wp-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-size: 0.688rem;
    font-weight: 500;
}

.wp-badge-success {
    background: #d1fae5;
    color: #065f46;
}

.wp-badge-secondary {
    background: #f1f5f9;
    color: #475569;
}

/* ========== Settings Grid ========== */
.wp-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.wp-setting-card {
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.wp-setting-card h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.wp-setting-card h4 i {
    color: #8352F1;
}

/* ========== Toggle Switch ========== */
.wp-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.wp-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.wp-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.2s;
    border-radius: 24px;
}

.wp-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
}

.wp-switch input:checked + .wp-slider {
    background-color: #8352F1;
}

.wp-switch input:checked + .wp-slider:before {
    transform: translateX(20px);
}

/* ========== Backup Section ========== */
.wp-backup-section {
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.wp-backup-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.938rem;
    font-weight: 600;
}

.wp-backup-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.wp-backup-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

.wp-backup-list li:last-child {
    border-bottom: none;
}

.wp-backup-list li div {
    display: flex;
    flex-direction: column;
}

.wp-backup-list li strong {
    font-size: 0.875rem;
    color: #1e293b;
}

.wp-backup-list li span {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.25rem;
}

.wp-backup-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ========== Management Grid ========== */
.wp-management-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.wp-mgmt-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.wp-mgmt-card:hover {
    background: #f8fafc;
}

.wp-mgmt-card i {
    font-size: 2rem;
    color: #8352F1;
    margin-bottom: 0.75rem;
}

.wp-mgmt-card h4 {
    margin: 0 0 0.375rem 0;
    font-size: 0.938rem;
    color: #1e293b;
}

.wp-mgmt-card p {
    margin: 0;
    font-size: 0.75rem;
    color: #64748b;
}

/* ========== Responsive Design ========== */
@media (max-width: 768px) {
    .wp-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .wp-header-right {
        width: 100%;
    }

    .wp-form-row {
        grid-template-columns: 1fr;
    }

    .wp-list-table {
        font-size: 0.75rem;
    }

    .wp-list-table th,
    .wp-list-table td {
        padding: 0.5rem;
    }

    .wp-action-buttons {
        flex-wrap: wrap;
        gap: 0.2rem;
    }

    .wp-modal-dialog {
        margin: 0.5rem;
    }
}

/* ========== Scrollbar Styling ========== */
.wp-plugin-list::-webkit-scrollbar,
.wp-theme-list::-webkit-scrollbar {
    width: 6px;
}

.wp-plugin-list::-webkit-scrollbar-track,
.wp-theme-list::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.wp-plugin-list::-webkit-scrollbar-thumb,
.wp-theme-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.wp-plugin-list::-webkit-scrollbar-thumb:hover,
.wp-theme-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ========== PHP Version Management ========== */
.wp-btn-php {
    background: linear-gradient(135deg, #8352F1 0%, #6F3DDB 100%);
    color: white;
    border: none;
}

.wp-btn-php:hover {
    background: linear-gradient(135deg, #8352F1 0%, #63397d 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(131, 82, 241, 0.3);
}

.wp-php-info {
    background: #f8fafc;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.wp-php-info p {
    margin: 0.5rem 0;
    font-size: 0.875rem;
    color: #334155;
}

.wp-php-info strong {
    color: #1e293b;
    font-weight: 600;
}

#phpCurrentVersion {
    font-weight: 600;
    font-size: 1rem;
}

.wp-alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.wp-alert i {
    font-size: 1.25rem;
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.wp-alert-info {
    background: #F6F2FE;
    border: 1px solid #D8C8FB;
    color: #5D2CC5;
}

.wp-alert-info i {
    color: #8352F1;
}

.wp-alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
}

.wp-alert-success i {
    color: #22c55e;
}

.wp-alert strong {
    display: block;
    margin-bottom: 0.25rem;
}

.wp-alert small {
    font-size: 0.75rem;
    opacity: 0.9;
}

/* PHP Version Modal Specific Styles */
#wpPHPVersionModal .wp-modal-body {
    padding: 1.5rem;
}

#wpPHPVersionModal select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background-color: white;
    color: #1e293b;
    transition: all 0.2s;
}

#wpPHPVersionModal select:focus {
    outline: none;
    border-color: #8352F1;
    box-shadow: 0 0 0 3px rgba(131, 82, 241, 0.1);
}

#wpPHPVersionModal select option {
    padding: 0.5rem;
}


/* Inline operation failures stay readable without changing modal layout. */
.wp-module-container .wp-action-error {
    padding: 10px 12px;
    margin: 0 0 12px;
    border: 1px solid #FECACA;
    border-radius: 8px;
    background: #FEF2F2;
    color: #B91C1C;
    font-size: 13px;
    overflow-wrap: anywhere;
}

/* Bound the administrator installation inventory to the content column.
   Long document roots wrap, and every action remains inside its own cell. */
.wp-module-container { min-width: 0; }
.wp-module-container .wp-header { flex-wrap: wrap; gap: 16px; }
.wp-module-container .wp-header-left { min-width: 0; }
.wp-module-container .wp-title { overflow-wrap: anywhere; }
.wp-module-container .wp-list-container { min-width: 0; max-width: 100%; overflow: visible; }
.wp-module-container #wp-list-content { min-width: 0; max-width: 100%; }
.wp-module-container .wp-installations-table-wrap { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; border-radius: 8px; }
.wp-module-container .wp-list-table { width: 100%; min-width: 0; table-layout: fixed; }
.wp-module-container .wp-list-table th:nth-child(1) { width: 18%; }
.wp-module-container .wp-list-table th:nth-child(2) { width: 27%; }
.wp-module-container .wp-list-table th:nth-child(3) { width: 7%; }
.wp-module-container .wp-list-table th:nth-child(4) { width: 10%; }
.wp-module-container .wp-list-table th:nth-child(5) { width: 13%; }
.wp-module-container .wp-list-table th:nth-child(6) { width: 10%; }
.wp-module-container .wp-list-table th:nth-child(7) { width: 15%; }
.wp-module-container .wp-list-table :is(td, th) { padding: 14px 12px; }
.wp-module-container .wp-list-table td { overflow-wrap: anywhere; }
.wp-module-container .wp-path code { display: block; max-width: 100%; white-space: normal; overflow-wrap: anywhere; font-size: 11px; line-height: 1.6; }
.wp-module-container .wp-list-table .wp-version-badge { max-width: 100%; overflow-wrap: anywhere; padding: 3px 7px; }
.wp-module-container .wp-actions-col, .wp-module-container .wp-list-table .wp-actions { white-space: normal; text-align: left; }
.wp-module-container .wp-action-buttons { display: grid; grid-template-columns: repeat(auto-fit, 34px); justify-content: start; gap: 6px; width: 100%; max-width: 100%; }
.wp-module-container .wp-action-buttons .wp-btn-icon { width: 34px; height: 34px; min-width: 34px; min-height: 34px; padding: 0; border-radius: 7px; flex: 0 0 34px; }
.wp-module-container .wp-action-buttons .wp-btn-icon:focus-visible { outline: 3px solid #BCA2F8; outline-offset: 2px; }
@media (max-width: 1250px) {
    .wp-module-container .wp-installations-table-wrap { overflow-x: auto; }
    .wp-module-container .wp-list-table, .wp-module-container .wp-list-table tbody { display: block; width: 100%; min-width: 0; }
    .wp-module-container .wp-list-table thead { display: none; }
    .wp-module-container .wp-list-table .wp-list-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; padding: 20px; }
    .wp-module-container .wp-list-table .wp-list-row:last-child { border-bottom: 0; }
    .wp-module-container .wp-list-table td { display: block; padding: 0; min-width: 0; border: 0; }
    .wp-module-container .wp-list-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 6px; color: #64748b; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
    .wp-module-container .wp-list-table :is(.wp-domain, .wp-path, .wp-actions) { grid-column: 1 / -1; }
    .wp-module-container .wp-action-buttons { grid-template-columns: repeat(auto-fit, 36px); gap: 8px; }
    .wp-module-container .wp-action-buttons .wp-btn-icon { width: 36px; height: 36px; min-width: 36px; min-height: 36px; }
}
@media (max-width: 640px) {
    .wp-module-container { padding: 0; }
    .wp-module-container .wp-header { padding: 18px 16px; }
    .wp-module-container .wp-header-right > button { width: 100%; justify-content: center; }
    .wp-module-container .wp-title { font-size: 20px; }
    .wp-module-container .wp-subtitle { line-height: 1.6; }
    .wp-module-container .wp-list-table .wp-list-row { padding: 16px; gap: 14px 20px; }
    .wp-module-container .wp-action-buttons { gap: 7px; }
}

/* Dialog controls use the same readable size as their list actions. */
.wp-module-container .wp-modal-dialog { min-width: 0; max-width: min(600px, 100%); }
.wp-module-container .wp-modal-lg { max-width: min(800px, 100%); }
.wp-module-container .wp-modal-header { gap: 12px; }
.wp-module-container .wp-modal-header h3 { min-width: 0; overflow-wrap: anywhere; }
.wp-module-container .wp-modal-close { flex: 0 0 auto; }
.wp-module-container .wp-modal .wp-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; height: auto; width: auto; max-width: 100%; padding: 8px 12px; line-height: 1.35; white-space: normal; }
.wp-module-container .wp-modal :is(.wp-form-group, .wp-form-row, .wp-setting-card) { min-width: 0; }
.wp-module-container .wp-modal .wp-form-group :is(input, select, textarea) { width: 100%; min-width: 0; max-width: 100%; }
.wp-module-container .wp-settings-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.wp-module-container .wp-setting-card { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.wp-module-container .wp-setting-card h4 { margin: 0; }
.wp-module-container .wp-setting-card :is(input.wp-input-sm, select.wp-input-sm) { width: 100%; max-width: 100%; min-width: 0; }
.wp-module-container :is(.wp-plugin-actions, .wp-theme-actions, .wp-backup-actions, .wp-modal-footer) { flex-wrap: wrap; }
.wp-module-container :is(.wp-plugin-actions, .wp-theme-actions) > input { flex: 1 1 160px; min-width: 0; max-width: 100%; }
.wp-module-container :is(.wp-plugin-table, .wp-theme-table) { table-layout: fixed; }
.wp-module-container :is(.wp-plugin-table, .wp-theme-table) td { overflow-wrap: anywhere; }
.wp-module-container .wp-backup-list li { flex-wrap: wrap; gap: 12px; }
.wp-module-container .wp-backup-list li > div { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
@media (max-width: 640px) {
    .wp-module-container .wp-modal { padding: 12px; }
    .wp-module-container .wp-modal-dialog { margin: 0; }
    .wp-module-container .wp-modal-header, .wp-module-container .wp-modal-body { padding: 16px; }
    .wp-module-container .wp-settings-grid { grid-template-columns: minmax(0, 1fr); }
}
