:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --surface: #0b1120;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --radius: 12px;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --surface: #f1f5f9;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Typography */
h1, h2, h3 {
    font-weight: 700;
    margin-bottom: 1rem;
}

.text-muted { color: var(--text-muted); font-size: 0.875rem; }

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-size: 0.875rem;
}

.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-dark); transform: translateY(-1px); }

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

/* Cards */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 1rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover { background-color: rgba(99, 102, 241, 0.05); }

/* Status Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
}

.status-active { background-color: #dcfce7; color: #166534; }
.status-blocked { background-color: #fee2e2; color: #991b1b; }
.status-canceled { background-color: #f1f5f9; color: #475569; }
.status-demo { background-color: #fef9c3; color: #854d0e; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
label { display: block; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.875rem; color: var(--text-main); }
input, select, textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--surface);
    color: var(--text-main);
    transition: all 0.3s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

/* Login Page */
.login-screen {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #1e1b4b 0%, #0f172a 60%, #020617 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 2.5rem;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Responsive / Mobile */
.mobile-header {
    display: none;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 1rem;
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        z-index: 50;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 45;
        backdrop-filter: blur(4px);
    }
    
    .sidebar-overlay.open {
        display: block;
    }

    .main-content {
        padding: 1rem;
    }

    .card {
        padding: 1rem;
    }

    div[style*="display: grid"] {
        grid-template-columns: 1fr !important;
    }

    /* Transform tables into cards on mobile */
    .table-container {
        overflow-x: hidden;
    }
    table, thead, tbody, th, td, tr {
        display: block;
    }
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    tr {
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 1rem;
        background-color: var(--surface);
    }
    td {
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        position: relative;
        padding: 1rem;
        text-align: left;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    td:before {
        position: static;
        width: 100%;
        text-align: left;
        font-weight: 600;
        color: var(--primary);
        font-size: 0.75rem;
        text-transform: uppercase;
        content: attr(data-label);
    }
    td:last-child {
        border-bottom: 0;
    }
    td > form {
        display: inline-block;
    }
    .empresa-row td[colspan="7"], .terminal-row td:first-child {
        display: none !important;
    }
}
