/* Emagre.Club - Modern SaaS Styling */

:root {
    --primary-color: #1D6A80;
    --primary-dark: #124d5e;
    --secondary-color: #8B4F8B;
    --accent-color: #04A6D5;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f1f5f9;
    --card-bg: #FEFEFE;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

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

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

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

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

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group label .required {
    color: var(--error-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    margin-top: 0.5rem;
}

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

.slider {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    background-color: #cbd5e1;
    border-radius: 34px;
    transition: .4s;
    margin-right: 12px;
}

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

.toggle-switch input:checked+.slider {
    background-color: var(--primary-color);
}

.toggle-switch input:focus+.slider {
    box-shadow: 0 0 1px var(--primary-color);
}

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

.toggle-label {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}


/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

/* Auth Pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.auth-box {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
}

.auth-box h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

.auth-form h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.auth-link {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--primary-color);
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* Dashboard */
.dashboard-page {
    min-height: 100vh;
}

.dashboard-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 0;
    /* Default collapsed */
    padding: 0;
    overflow: hidden;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.sidebar.open {
    width: 250px;
    padding: 1.5rem;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 1rem;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-header h2 {
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.user-info {
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 0.5rem;
    margin-bottom: 2rem;
}

.role-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 0.5rem;
}

.role-badge.role-super_admin {
    background: #fef3c7;
    color: #92400e;
}

.role-badge.role-admin {
    background: #dbeafe;
    color: #1e40af;
}

.role-badge.role-affiliate {
    background: #d1fae5;
    color: #065f46;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}

.nav-item:hover {
    background-color: var(--bg-color);
}

.nav-item.logout {
    margin-top: auto;
    color: var(--error-color);
}

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

.dashboard-content h1 {
    margin-bottom: 2rem;
    color: var(--text-primary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}

.stat-card h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Tables */
.data-table {
    width: 100%;
    background: var(--card-bg);
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table thead {
    background: var(--bg-color);
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

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

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

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status-badge.status-pending {
    background: #fef3c7;
    color: #92400e;
    /* Yellow */
}

.status-badge.status-scheduled {
    background: #dbeafe;
    color: #1e40af;
    /* Blue */
}

.status-badge.status-attended {
    background: #f3e8ff;
    color: #6b21a8;
    /* Lilac */
}

.status-badge.status-missed {
    background: #ffedd5;
    color: #9a3412;
    /* Orange */
}

.status-badge.status-not_purchased {
    background: #fee2e2;
    color: #991b1b;
    /* Red */
}

.status-badge.status-purchased {
    background: #dcfce7;
    color: #166534;
    /* Green */
    font-weight: 600;
}

.status-badge.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.status-inactive {
    background: #fee2e2;
    color: #991b1b;
}

/* Referral Link Section */
.referral-link-section {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.referral-link-box {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.referral-link-box input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-family: monospace;
}

.referral-code {
    margin-top: 1rem;
    color: var(--text-secondary);
}

/* Referral Form */
.referral-form-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.referral-form-container {
    max-width: 600px;
    width: 100%;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
}

.referral-form-container h1 {
    margin-bottom: 1rem;
    text-align: center;
}

.company-name {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-secondary);
}

/* Success Page */
.success-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.success-container {
    text-align: center;
    max-width: 500px;
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 2rem;
    background: var(--success-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: bold;
}

/* Home Page */
.home-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero {
    text-align: center;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.hero p {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Inline Form */
.inline-form {
    display: inline;
}

.status-select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

/* Actions */
.actions {
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.text-muted {
    color: var(--text-secondary);
}

.text-error {
    color: var(--error-color);
}

/* Error Page */
.error-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.error-page h1 {
    font-size: 6rem;
    color: var(--error-color);
    margin-bottom: 1rem;
}

.error-page p {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Dashboard Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    gap: 1rem;
}

.dashboard-header h1 {
    margin-bottom: 0.5rem;
}

.company-name {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

/* Companies Grid */
.companies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.company-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.company-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.company-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.company-card-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.company-card-stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.btn-block {
    width: 100%;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar.open {
        width: 100%;
        height: auto;
        padding: 1.5rem;
    }

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

    .hero h1 {
        font-size: 2rem;
    }

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

    .dashboard-header {
        flex-direction: column;
    }

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

/* Top Bar Switcher */
.top-bar {
    background: var(--card-bg);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 2rem;
}

.company-switcher {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.company-switcher label {
    font-weight: 500;
    color: var(--text-secondary);
}

.company-switcher select {
    padding: 0.5rem 2rem 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background-color: var(--bg-color);
    cursor: pointer;
    min-width: 200px;
}

/* Scrollable Checkbox List */
.checkbox-list {
    margin-top: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 0.5rem;
    background-color: var(--bg-color);
}

.checkbox-list label.toggle-switch {
    font-weight: normal;
    display: flex;
    align-items: center;
}

.checkbox-list .toggle-label {
    font-size: 0.9rem;
    margin-left: 0.5rem;
}