:root {
    --bg-color: #0b0e14;
    --sidebar-bg: #12161f;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #0084ff;
    --primary-glow: rgba(0, 132, 255, 0.5);
    --secondary: #6e41e2;
    --text-main: #ffffff;
    --text-muted: #8b949e;
    --accent-success: #2ea043;
    --accent-error: #f85149;
    --accent-warning: #d29922;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    height: 100vh;
}

h1, h2, h3, .logo h1 {
    font-family: 'Outfit', sans-serif;
    color: #ffffff !important;
}

label {
    color: rgba(255, 255, 255, 0.7) !important;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.logo-icon {
    font-size: 2.5rem;
    color: var(--primary);
    line-height: 1;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
}

.logo h1 span {
    color: var(--primary);
}

.main-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    text-align: left;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
}

.nav-item:hover:not(:disabled) {
    background-color: var(--glass-bg);
    color: var(--text-main);
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 0 20px var(--primary-glow);
}

.nav-item:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.nav-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 1.5rem 0;
}

.sidebar-footer {
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-success);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-success);
}

/* Main Content */
.content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem 3rem;
    overflow-y: auto;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.search-bar input {
    background-color: var(--sidebar-bg);
    border: 1px solid var(--glass-border);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    color: white;
    width: 400px;
    outline: none;
    transition: var(--transition);
}

.search-bar input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 132, 255, 0.2);
}

.icon-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--primary);
    transform: rotate(45deg);
}

/* Views & Cards */
.view {
    animation: fadeIn 0.4s ease-out;
}

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

.hidden {
    display: none !important;
}

.card {
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}

.glass {
    background: var(--glass-bg);
    transition: var(--transition);
}

.glass:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-with-button {
    display: flex;
    gap: 1rem;
}

input[type="text"], input[type="password"], input[type="email"] {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    padding: 0.85rem 1rem;
    border-radius: 12px;
    color: white;
    width: 100%;
    font-size: 1rem;
}

input::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: var(--transition);
}

.btn-text:hover {
    color: white;
    text-shadow: 0 0 10px var(--primary-glow);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-card h3 {
    color: rgba(255, 255, 255, 0.7) !important;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, #8b949e);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.action-card {
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
}

.action-icon {
    font-size: 2.5rem;
    background: var(--glass-bg);
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
}

/* Results Content */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.results-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.data-card {
    padding: 1.5rem;
    background: var(--glass-bg);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    transition: var(--transition);
}

.data-card:hover {
    transform: scale(1.02);
    border-color: var(--primary);
}

.data-card h4 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.data-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.data-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.metric-item {
    background: rgba(0,0,0,0.2);
    padding: 0.5rem;
    border-radius: 8px;
}

.metric-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.metric-val {
    font-weight: 600;
    font-size: 0.9rem;
}

/* Loader */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 5rem;
}

.loader {
    width: 50px;
    height: 50px;
    border: 5px solid var(--glass-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Tables */
.table-container {
    overflow-x: auto;
    background: var(--glass-bg);
    border-radius: 20px;
    padding: 1rem;
}

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

th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--glass-border);
}

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

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255,255,255,0.02);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active { background: rgba(46, 160, 67, 0.15); color: var(--accent-success); }
.badge-paused { background: rgba(248, 81, 73, 0.15); color: var(--accent-error); }

/* Custom Switch for Meta Ads */
.status-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
}

.status-toggle span {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background-color: var(--accent-success);
    border-color: rgba(46, 160, 67, 0.3);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--accent-success);
}

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


/* JSON */
.json-container {
    background: #010409;
    padding: 2rem;
    border-radius: 20px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    border: 1px solid var(--glass-border);
}

#json-output {
    white-space: pre-wrap;
    word-break: break-all;
}

/* Notifications */
#notification-area {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 9999;
}

.notification {
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    color: white;
    font-weight: 500;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.notification.success { background: rgba(46, 160, 67, 0.9); border: 1px solid rgba(46, 160, 67, 0.3); }
.notification.error { background: rgba(248, 81, 73, 0.9); border: 1px solid rgba(248, 81, 73, 0.3); }
.notification.info { background: rgba(0, 132, 255, 0.9); border: 1px solid rgba(0, 132, 255, 0.3); }

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Footer Styles */
.app-footer {
    padding: 2rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--glass-border);
    margin-top: auto;
}

.login-footer {
    border-top: none;
    margin-top: 2rem;
}

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

.app-footer a:hover {
    color: white;
    text-shadow: 0 0 10px var(--primary-glow);
}

/* Multi-Cuenta Styles */
.user-config {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.dropdown-select {
    background-color: #0b0e14;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    font-family: inherit;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.4)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 0.85em;
    padding-right: 2.75rem;
    min-width: 200px;
    transition: all 0.2s ease;
}

.dropdown-select:hover {
    background-color: #12161f;
    border-color: rgba(255, 255, 255, 0.2);
}

.dropdown-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 132, 255, 0.1);
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.config-grid > .card:last-child {
    grid-column: 1 / -1;
}

.company-list-card {
    display: flex;
    flex-direction: column;
}

.companies-list {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.company-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.company-info .company-name {
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.company-info .company-token {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.btn-danger {
    background: rgba(248, 81, 73, 0.1);
    color: var(--accent-error);
    border: 1px solid rgba(248, 81, 73, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: var(--transition);
}

.btn-danger:hover {
    background: var(--accent-error);
    color: white;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.active-badge {
    background: rgba(46, 160, 67, 0.2);
    color: var(--accent-success);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Login Styles */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, rgba(0, 132, 255, 0.1) 0%, var(--bg-color) 70%);
    z-index: 1000;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 3rem;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    backdrop-filter: blur(20px);
}

.login-logo {
    justify-content: center;
    margin-bottom: 2rem;
}

.login-card h2 {
    margin-bottom: 0.5rem;
}

.login-card .subtitle {
    margin-bottom: 2.5rem;
}

.login-card .form-group {
    text-align: left;
}

.login-actions {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid transparent;
}

.btn-danger-outline:hover:not(:disabled) {
    background: rgba(248, 81, 73, 0.1);
    border-color: rgba(248, 81, 73, 0.3);
}

.hidden-login {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* Landing Builder Styles */
.builder-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    align-items: start;
    margin-top: 2rem;
}

.builder-form textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid var(--glass-border);
    padding: 1rem;
    border-radius: 12px;
    color: white;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
}

.builder-form textarea:focus {
    border-color: var(--primary);
}

.builder-fields {
    margin: 2rem 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.builder-preview h3 {
    margin-bottom: 0.5rem;
}

.preview-container {
    width: 100%;
    min-height: 600px;
    background: white;
    border-radius: 12px;
    overflow-y: auto;
    border: none;
    margin-top: 1rem;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.lp-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    font-style: italic;
    background: #f8f9fa;
    position: absolute;
    inset: 0;
    padding: 2rem;
    text-align: center;
}

input[type="color"] {
    height: 45px;
    padding: 0.2rem;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    width: 100%;
}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 992px) {
    .app-container {
        flex-direction: column;
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 1050;
        transition: var(--transition);
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    }

    .sidebar.active {
        left: 0;
    }

    .content {
        padding: 1rem !important;
    }

    .top-bar {
        gap: 1rem;
        margin-bottom: 1.5rem !important;
    }

    .user-config {
        width: auto;
        flex-grow: 0;
    }

    .dropdown-select {
        min-width: 120px;
        max-width: 180px;
        font-size: 0.75rem;
        padding: 0.5rem 2rem 0.5rem 0.75rem;
    }

    .search-bar {
        flex-grow: 1;
    }

    .search-bar input {
        width: 100% !important;
        padding: 0.6rem 1.25rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    .data-metrics {
        grid-template-columns: 1fr;
    }
    
    .config-grid {
        grid-template-columns: 1fr;
    }

    .action-grid {
        grid-template-columns: 1fr;
    }

    
    .stat-value {
        font-size: 1.8rem;
    }
}

