/* ============================================
   ZeroDesk - Portal de VMs
   ============================================ */

:root {
    --primary: #F2C31C;
    --primary-hover: #d9ad14;
    --primary-light: #fef9e7;
    --primary-dark: #2a2d3a;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
    --shadow-xl: 0 20px 25px rgba(0,0,0,.1), 0 10px 10px rgba(0,0,0,.04);
    --transition: 150ms cubic-bezier(.4,0,.2,1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   Login Page
   ============================================ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #2a2d3a 50%, #16213e 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 40px 36px;
    box-shadow: var(--shadow-xl);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 16px;
}

.login-brand-icon {
    width: 40px;
    height: 40px;
}

.login-brand h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--gray-900);
    margin: 0;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.login-tagline {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin: 0;
}

.login-logo {
    max-height: 56px;
    margin-bottom: 16px;
}

.login-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper svg {
    position: absolute;
    left: 12px;
    color: var(--gray-400);
    pointer-events: none;
    flex-shrink: 0;
}

.input-wrapper input,
.input-wrapper select {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--gray-800);
    background: var(--gray-50);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.input-wrapper input:focus,
.input-wrapper select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(242, 195, 28, 0.2);
    background: #fff;
}

.input-wrapper input::placeholder {
    color: var(--gray-400);
}

.login-footer {
    text-align: center;
    color: rgba(255,255,255,.5);
    font-size: 0.8rem;
    margin-top: 20px;
}

.login-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.login-footer a:hover {
    text-decoration: underline;
}

/* Alert */
.alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 20px;
}

.alert-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fecaca;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover:not(:disabled) {
    background: #15803d;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
}

.btn-outline {
    background: transparent;
    color: var(--gray-600);
    border: 1.5px solid var(--gray-200);
}

.btn-outline:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 8px;
}

/* ============================================
   Dashboard
   ============================================ */

.dashboard-page {
    background: var(--gray-50);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--primary-dark);
    border-bottom: 1px solid rgba(255,255,255,.08);
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

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

.topbar-logo {
    height: 32px;
    width: 32px;
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255,255,255,.7);
    font-size: 0.875rem;
    font-weight: 500;
}

.topbar-right .btn-outline {
    color: rgba(255,255,255,.7);
    border-color: rgba(255,255,255,.15);
}

.topbar-right .btn-outline:hover:not(:disabled) {
    background: rgba(255,255,255,.08);
    border-color: rgba(255,255,255,.25);
    color: #fff;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    flex: 1;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.dashboard-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

/* Footer */
.dashboard-footer {
    text-align: center;
    padding: 16px 24px;
    color: var(--gray-400);
    font-size: 0.8rem;
    border-top: 1px solid var(--gray-200);
    background: #fff;
}

.dashboard-footer a {
    color: var(--gray-600);
    text-decoration: none;
    font-weight: 600;
}

.dashboard-footer a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ============================================
   VM Grid
   ============================================ */

.vm-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
    gap: 20px;
}

.vm-card {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
}

.vm-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Thumbnail */
.vm-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #1a1a2e;
    overflow: hidden;
    cursor: default;
}

.vm-thumb.has-thumb {
    cursor: pointer;
}

.vm-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity .4s ease;
}

.vm-thumb-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner-sm {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255,255,255,.15);
    border-top-color: rgba(255,255,255,.5);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.vm-thumb-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity .2s ease;
}

.vm-thumb.has-thumb:hover .vm-thumb-overlay {
    opacity: 1;
}

.vm-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: rgba(255,255,255,.25);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.vm-thumb-placeholder.running {
    background: linear-gradient(135deg, #0f2027, #1a3a2a);
    color: rgba(255,255,255,.35);
}

.vm-thumb-placeholder.stopped {
    background: linear-gradient(135deg, #1a1a2e, #2a2040);
}

.vm-card-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-100);
}

.vm-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.vm-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.vm-icon.running {
    background: var(--success-light);
    color: var(--success);
}

.vm-icon.stopped {
    background: var(--gray-100);
    color: var(--gray-400);
}

.vm-icon.paused {
    background: var(--warning-light);
    color: var(--warning);
}

.vm-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vm-id {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.vm-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.vm-status-badge.running {
    background: var(--success-light);
    color: var(--success);
}

.vm-status-badge.stopped {
    background: var(--gray-100);
    color: var(--gray-500);
}

.vm-status-badge.paused {
    background: var(--warning-light);
    color: var(--warning);
}

.vm-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.vm-status-badge.running .vm-status-dot {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.vm-card-body {
    padding: 16px 20px;
}

.vm-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.vm-stat {
    text-align: center;
}

.vm-stat-label {
    font-size: 0.7rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.vm-stat-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
}

.vm-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.vm-actions .btn {
    flex: 1;
    min-width: 0;
}

/* ============================================
   States
   ============================================ */

.loading-state,
.empty-state,
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--gray-500);
    text-align: center;
}

.loading-state p,
.empty-state p,
.error-state p {
    margin-top: 16px;
    font-size: 1rem;
    font-weight: 500;
}

.empty-state small,
.error-state small {
    font-size: 0.85rem;
    color: var(--gray-400);
    margin-top: 4px;
}

.empty-state svg,
.error-state svg {
    color: var(--gray-300);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

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

/* ============================================
   Modal
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 600px;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-400);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.btn-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.modal-body {
    flex: 1;
    overflow: hidden;
}

/* ============================================
   Toast
   ============================================ */

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

.toast {
    background: var(--gray-800);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn .3s ease;
    max-width: 360px;
}

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

.toast { cursor: pointer; }
.toast-text { flex: 1; }
.toast-close {
    background: transparent;
    color: rgba(255,255,255,.7);
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0 4px;
    margin-left: 4px;
}
.toast-close:hover { color: #fff; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============================================
   Setup page (setup.php)
   ============================================ */

.setup-page { background: var(--gray-50); min-height: 100vh; }
.setup-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #2a2d3a 50%, #16213e 100%);
    color: #fff;
    padding: 48px 24px 72px;
    text-align: center;
}
.setup-header .brand {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; margin-bottom: 20px;
}
.setup-header .brand img { width: 36px; height: 36px; }
.setup-header .brand span { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.setup-header h1 { font-size: 1.75rem; margin-bottom: 8px; }
.setup-header p {
    color: rgba(255,255,255,.65); font-size: 1rem;
    max-width: 500px; margin: 0 auto;
}
.setup-container { max-width: 720px; margin: -40px auto 40px; padding: 0 24px; }

.hero-card {
    background: #fff; border-radius: 16px; border: 1px solid var(--gray-200);
    padding: 40px 36px; margin-bottom: 24px;
    box-shadow: 0 4px 24px rgba(0,0,0,.08); text-align: center;
}
.hero-card .icon-circle {
    width: 72px; height: 72px; border-radius: 50%;
    background: linear-gradient(135deg, #F2C31C 0%, #e6a800 100%);
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 20px; box-shadow: 0 4px 16px rgba(242, 195, 28, .3);
}
.hero-card .icon-circle svg { color: #1a1a2e; }
.hero-card h2 { font-size: 1.35rem; color: var(--gray-900); margin-bottom: 8px; }
.hero-card .subtitle {
    color: var(--gray-500); font-size: 0.95rem;
    margin-bottom: 28px; line-height: 1.6;
}

.download-hero {
    display: inline-flex; align-items: center; gap: 12px;
    padding: 16px 36px;
    background: linear-gradient(135deg, #F2C31C 0%, #e6a800 100%);
    color: #1a1a2e; border-radius: 12px;
    text-decoration: none; font-weight: 700; font-size: 1.05rem;
    transition: all .2s ease;
    box-shadow: 0 4px 16px rgba(242, 195, 28, .3);
}
.download-hero:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(242, 195, 28, .4);
}
.download-hero .meta { font-weight: 400; font-size: 0.85rem; opacity: 0.7; }

.features-row {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 12px; margin-top: 28px;
}
.feature-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; padding: 14px 8px;
    background: var(--gray-50); border-radius: 10px;
}
.feature-item svg { color: var(--primary); }
.feature-item span {
    font-size: 0.8rem; color: var(--gray-600);
    text-align: center; line-height: 1.3;
}

.step-card {
    background: #fff; border-radius: 14px; border: 1px solid var(--gray-200);
    padding: 28px 32px; margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.step-header {
    display: flex; align-items: center; gap: 14px; margin-bottom: 14px;
}
.step-number {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); color: #1a1a2e;
    font-weight: 700; font-size: 0.9rem; flex-shrink: 0;
}
.step-header h3 { font-size: 1.05rem; color: var(--gray-900); margin: 0; }
.step-card p, .step-card li {
    color: var(--gray-600); line-height: 1.7; font-size: 0.92rem;
}
.step-card ol { padding-left: 20px; margin: 8px 0 0; }
.step-card li { margin-bottom: 6px; }

.info-box, .warning-box, .success-box {
    border-radius: 10px; padding: 14px 18px; margin: 14px 0 0;
    display: flex; gap: 10px; align-items: flex-start;
}
.info-box { background: #f0f7ff; border: 1px solid #bfdbfe; }
.warning-box { background: #fffbeb; border: 1px solid #fde68a; }
.success-box { background: #f0fdf4; border: 1px solid #bbf7d0; }
.info-box svg, .warning-box svg, .success-box svg { flex-shrink: 0; margin-top: 2px; }
.info-box svg { color: #3b82f6; }
.warning-box svg { color: #f59e0b; }
.success-box svg { color: #22c55e; }
.info-box p, .warning-box p, .success-box p {
    color: var(--gray-700); font-size: 0.88rem; margin: 0; line-height: 1.6;
}

.faq-card {
    background: #fff; border-radius: 14px; border: 1px solid var(--gray-200);
    padding: 28px 32px; margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.faq-card h2 { font-size: 1.1rem; color: var(--gray-900); margin-bottom: 12px; }
.faq { margin-top: 4px; border-bottom: 1px solid var(--gray-100); }
.faq:last-child { border-bottom: none; }
.faq summary {
    cursor: pointer; font-weight: 600; color: var(--gray-700);
    padding: 12px 0; font-size: 0.92rem; list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before {
    content: '+';
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--gray-100); color: var(--gray-500);
    font-size: 1rem; margin-right: 10px; font-weight: 400;
    transition: all .2s;
}
.faq[open] summary::before {
    content: '−'; background: var(--primary); color: #1a1a2e;
}
.faq summary:hover { color: var(--primary); }
.faq .answer {
    padding: 4px 0 16px 32px;
    color: var(--gray-600); font-size: 0.88rem; line-height: 1.7;
}

.back-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: rgba(255,255,255,.6); text-decoration: none;
    font-size: 0.88rem; margin-bottom: 20px; transition: color .2s;
}
.back-link:hover { color: #fff; }

@media (max-width: 600px) {
    .setup-header { padding: 32px 16px 56px; }
    .setup-header h1 { font-size: 1.35rem; }
    .setup-container { padding: 0 16px; }
    .hero-card { padding: 28px 20px; }
    .step-card, .faq-card { padding: 22px 20px; }
    .features-row { grid-template-columns: 1fr; gap: 8px; }
    .download-hero { padding: 14px 24px; font-size: 0.95rem; }
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .vm-grid {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar-user {
        display: none;
    }

    .login-card {
        padding: 28px 24px;
    }

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

    .vm-actions .btn {
        flex: auto;
    }
}

@media (max-width: 480px) {
    .dashboard-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}
