/* ================================
   Dashboard Layout & Dark Theme
   Overrides app.css styles for dashboard pages
   ================================ */

/* Reset app.css dashboard-page styles for dark theme dashboard */
.dashboard-layout .dashboard-page {
    padding-top: 0 !important;
    min-height: auto !important;
    background: transparent !important;
}

/* Dashboard Layout Container */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
}

/* Main Content Area */
.dashboard-main {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
    overflow-y: auto;
    min-height: 100vh;
}

/* Sidebar */
.dashboard-sidebar {
    width: 280px;
    height: 100vh;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    border-right: 1px solid rgba(99, 102, 241, 0.1);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
}

.logo-icon {
    font-size: 1.5rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(99, 102, 241, 0.1);
    color: #fff;
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
    border-left-color: #6366f1;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 0;
    border-top: 1px solid rgba(99, 102, 241, 0.1);
}

/* Dashboard Page Content */
.dashboard-page {
    max-width: 1400px;
    animation: fadeIn 0.3s ease-in;
    color: #fff;
}

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

/* Dashboard Header */
.dashboard-header {
    margin-bottom: 2rem;
}

.dashboard-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 0.5rem;
}

.dashboard-header p {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

/* Stats Card */
.stats-card {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.stats-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(99, 102, 241, 0.15);
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.stats-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stats-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

.stats-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    width: fit-content;
}

.stats-trend svg {
    width: 12px;
    height: 12px;
}

.stats-trend.up {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.stats-trend.down {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.stats-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stats-icon svg {
    width: 24px;
    height: 24px;
}

.stats-icon.primary {
    background: rgba(99, 102, 241, 0.2);
    color: #6366f1;
}

.stats-icon.success {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.stats-icon.warning {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.stats-icon.danger {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.stats-value {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
}

.stats-subtitle {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.5rem;
}

/* Dashboard Sections */
.dashboard-section {
    margin-bottom: 2.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

/* Campaign Table */
.campaign-table-wrapper {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    overflow: hidden;
}

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

.campaign-table thead {
    background: rgba(99, 102, 241, 0.1);
}

.campaign-table th {
    padding: 1rem;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
}

.campaign-table td {
    padding: 1rem;
    color: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.campaign-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.campaign-table tbody tr:last-child td {
    border-bottom: none;
}

.campaign-name {
    font-weight: 600;
    color: #fff;
}

.campaign-date {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.25rem;
}

.campaign-subject {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.draft {
    background: rgba(156, 163, 175, 0.2);
    color: #9ca3af;
}

.status-badge.scheduled {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.status-badge.sent, .status-badge.active {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.status-badge.paused {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

/* Stat Values with color */
.stat-value.good {
    color: #10b981;
}

.stat-value.average {
    color: #f59e0b;
}

.stat-value.poor {
    color: #ef4444;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.5rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 6px;
    color: #6366f1;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: scale(1.05);
}

.action-btn.danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.action-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: rgba(255, 255, 255, 0.5);
}

/* Button Styles for Dashboard */
.dashboard-layout .btn-outline {
    padding: 0.625rem 1.25rem;
    border: 1px solid rgba(99, 102, 241, 0.5);
    border-radius: 8px;
    color: #6366f1;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
    background: transparent;
}

.dashboard-layout .btn-outline:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: #6366f1;
}

.dashboard-layout .btn-primary {
    padding: 0.625rem 1.25rem;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    border-radius: 8px;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
    cursor: pointer;
}

.dashboard-layout .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    color: rgba(255, 255, 255, 0.7);
}

.loading-state .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(99, 102, 241, 0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

/* Auth Loading/Required */
.auth-loading,
.auth-required {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
}

.auth-loading {
    flex-direction: column;
    gap: 1rem;
}

.auth-loading .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(99, 102, 241, 0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.auth-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 3rem;
    text-align: center;
    max-width: 400px;
}

.auth-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #fff;
}

.auth-card p {
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 2rem;
}

.auth-card .btn-primary {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.auth-card .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

/* Responsive Design */
@media (max-width: 1280px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .dashboard-main {
        margin-left: 0;
        padding: 1rem;
    }

    .dashboard-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .dashboard-sidebar.open {
        transform: translateX(0);
    }

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

    .campaign-table {
        display: block;
        overflow-x: auto;
    }

    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
}

/* Template Card */
.template-card {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(99, 102, 241, 0.15);
}

.template-preview {
    height: 150px;
    background: rgba(99, 102, 241, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-preview svg {
    width: 48px;
    height: 48px;
    color: rgba(255, 255, 255, 0.3);
}

.template-info {
    padding: 1rem;
}

.template-name {
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.25rem;
}

.template-category {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

/* Automations List */
.automations-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.automation-item {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.automation-info h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    margin: 0 0 0.25rem;
}

.automation-trigger {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
}

.automation-stats {
    display: flex;
    gap: 2rem;
    align-items: center;
}

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

.automation-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.automation-stat-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

/* Subscribers Grid */
.subscribers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.subscriber-card {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
}

.subscriber-email {
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.25rem;
}

.subscriber-name {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.5rem;
}

.subscriber-date {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
}

/* Charts placeholder */
.chart-placeholder {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 2rem;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.5);
}

/* Form elements in dashboard */
.dashboard-layout input[type="text"],
.dashboard-layout input[type="email"],
.dashboard-layout input[type="search"],
.dashboard-layout select,
.dashboard-layout textarea {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: #fff;
    width: 100%;
    transition: all 0.2s;
}

.dashboard-layout input[type="text"]:focus,
.dashboard-layout input[type="email"]:focus,
.dashboard-layout input[type="search"]:focus,
.dashboard-layout select:focus,
.dashboard-layout textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.dashboard-layout input::placeholder,
.dashboard-layout textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-switch.active {
    background: #6366f1;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.toggle-switch.active::after {
    transform: translateX(24px);
}
