/* Light theme (default) */
:root, [data-theme="light"] {
    --bg: #f5f6fa;
    --bg-card: #ffffff;
    --bg-hover: #f0f1f5;
    --bg-input: #ffffff;
    --border: #e2e4ea;
    --border-focus: #4f7df9;
    --text: #1a1d27;
    --text-muted: #5c6078;
    --text-dim: #8b8fa3;
    --primary: #4f7df9;
    --primary-hover: #3d6be8;
    --primary-bg: rgba(79,125,249,0.08);
    --success: #16a34a;
    --success-bg: rgba(22,163,74,0.08);
    --warning: #d97706;
    --warning-bg: rgba(217,119,6,0.08);
    --danger: #dc2626;
    --danger-bg: rgba(220,38,38,0.08);
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

/* Dark theme */
[data-theme="dark"] {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-hover: #222633;
    --bg-input: #141722;
    --border: #2a2e3d;
    --border-focus: #4f7df9;
    --text: #e4e6ed;
    --text-muted: #8b8fa3;
    --text-dim: #5c6078;
    --primary: #4f7df9;
    --primary-hover: #3d6be8;
    --primary-bg: rgba(79,125,249,0.1);
    --success: #34d399;
    --success-bg: rgba(52,211,153,0.1);
    --warning: #fbbf24;
    --warning-bg: rgba(251,191,36,0.1);
    --danger: #f87171;
    --danger-bg: rgba(248,113,113,0.1);
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

/* Theme toggle button */
.theme-toggle {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.theme-toggle svg { width: 16px; height: 16px; }

.theme-toggle .icon-sun,
.theme-toggle .icon-moon { display: none; }

[data-theme="light"] .theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.header h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.whm-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--warning);
    background: var(--warning-bg);
    text-decoration: none;
    transition: opacity 0.15s;
}

.whm-link:hover { opacity: 0.8; }

.badge {
    background: var(--primary-bg);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.stats {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.stat-dot.green { background: var(--success); }
.stat-dot.yellow { background: var(--warning); }
.stat-dot.blue { background: var(--primary); }

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--text-dim);
    pointer-events: none;
}

.search-box input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 70px 8px 36px;
    color: var(--text);
    font-size: 13px;
    width: 320px;
    transition: border-color 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--border-focus);
}

.search-box kbd {
    position: absolute;
    right: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    color: var(--text-dim);
    font-family: inherit;
}

select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}

select:focus { outline: none; border-color: var(--border-focus); }

/* Filtro WordPress / Estaticas */
.seg {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.seg button {
    background: var(--bg-input);
    border: none;
    border-right: 1px solid var(--border);
    padding: 8px 12px;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
}
.seg button:last-child { border-right: none; }
.seg button:hover { background: var(--bg-hover); }
.seg button.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.seg button span { font-size: 11px; opacity: 0.7; margin-left: 2px; }

.type-badge {
    margin-left: 8px;
    padding: 2px 8px;
    border: none;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    vertical-align: middle;
}
.type-badge.wp { color: var(--warning); background: var(--warning-bg); }
.type-badge.static { color: var(--success); background: var(--success-bg); }
.type-badge:hover { opacity: 0.8; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn svg { width: 15px; height: 15px; }

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--border);
}

.btn-icon svg { width: 16px; height: 16px; }

.btn-icon.btn-open { color: var(--primary); }
.btn-icon.btn-open:hover { background: var(--primary-bg); }

.btn-icon.btn-wp { color: #21759b; }
.btn-icon.btn-wp:hover { background: rgba(33,117,155,0.15); }

.btn-icon.btn-delete { color: var(--text-dim); }
.btn-icon.btn-delete:hover { color: var(--danger); background: var(--danger-bg); }

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
}
.btn-danger:hover { background: #ef4444; }

/* Table */
.table-container {
    padding: 0 24px 24px;
    overflow-x: auto;
}

.main-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 4px;
}

.main-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg);
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    z-index: 10;
}

.main-table thead th.sortable {
    cursor: pointer;
    user-select: none;
}

.main-table thead th.sortable:hover { color: var(--text-muted); }

.sort-icon {
    width: 12px;
    height: 12px;
    vertical-align: middle;
    opacity: 0.4;
    transition: transform 0.2s, opacity 0.2s;
}

.sort-asc .sort-icon { transform: rotate(180deg); opacity: 1; }
.sort-desc .sort-icon { opacity: 1; }

.main-table tbody tr {
    transition: background 0.1s;
}

.main-table tbody tr:hover { background: var(--bg-hover); }

.main-table td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.col-status { width: 40px; text-align: center; }
.col-status svg { width: 14px; height: 14px; }
.col-domain { min-width: 200px; }
.col-access { width: 70px; text-align: center; }
.col-wp { width: 70px; text-align: center; }
.col-phone { min-width: 120px; white-space: nowrap; }
.col-user { min-width: 120px; }
.col-pass { min-width: 120px; }
.col-notes { min-width: 100px; max-width: 200px; }
.col-actions { width: 90px; text-align: center; }

.notes-text {
    font-size: 12px;
    color: var(--text-dim);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Status indicator */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active { background: var(--success); box-shadow: 0 0 6px rgba(52,211,153,0.4); }
.status-dot.inactive { background: var(--danger); }

/* Domain cell */
.domain-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.domain-name {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
}

.domain-meta {
    font-size: 11px;
    color: var(--text-dim);
}

/* Credential display */
.cred-value {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.cred-value .copy-btn {
    opacity: 0;
    transition: opacity 0.15s;
}

tr:hover .cred-value .copy-btn { opacity: 1; }

.cred-empty {
    color: var(--text-dim);
    font-style: italic;
    font-size: 12px;
}

.password-mask {
    letter-spacing: 2px;
    cursor: pointer;
}

.password-mask:hover { color: var(--text); }

/* Disk bar */
.disk-bar-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.disk-bar {
    width: 80px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.disk-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}

.disk-bar-fill.low { background: var(--success); }
.disk-bar-fill.medium { background: var(--warning); }
.disk-bar-fill.high { background: var(--danger); }

.disk-text {
    font-size: 11px;
    color: var(--text-dim);
}

/* Package tag */
.package-tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

/* Loading */
.loading-row td {
    text-align: center;
    padding: 60px 0;
    color: var(--text-dim);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 12px;
}

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

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

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 560px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-header h2 { font-size: 18px; font-weight: 700; }

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.modal-close:hover { background: var(--bg-hover); color: var(--text); }

.modal-body { padding: 20px 24px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 24px 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--border-focus);
}

.input-readonly {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.password-field {
    position: relative;
}

.password-field input { padding-right: 40px; }

.btn-eye {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.btn-eye:hover { color: var(--text); }
.btn-eye svg { width: 16px; height: 16px; }

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    color: var(--text) !important;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastIn 0.3s ease;
    min-width: 250px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Responsive */
@media (max-width: 768px) {
    .header { flex-direction: column; gap: 8px; align-items: flex-start; }
    .stats { display: none; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-left, .toolbar-right { flex-direction: column; }
    .search-box input { width: 100%; }
    .form-row { grid-template-columns: 1fr; }
    .col-notes { display: none; }
}

/* User menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 16px;
    padding-left: 16px;
    border-left: 1px solid var(--border);
}

.user-name {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
    gap: 4px;
    text-decoration: none;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
