/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --background: #0f172a;
    --surface: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

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

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: var(--surface);
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
}

.auth-card h1 {
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 15px;
    transition: border-color 0.2s;
    background: var(--background);
    color: var(--text-primary);
}

.form-group input: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: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
}

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

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

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

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

.btn-block {
    width: 100%;
    display: block;
}

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

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

/* Messages */
.error-message, .success-message {
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
}

.error-message {
    background: #7f1d1d;
    color: #fecaca;
    border: 1px solid #991b1b;
}

.success-message {
    background: #064e3b;
    color: #a7f3d0;
    border: 1px solid #065f46;
}

/* Auth Footer */
.auth-footer {
    margin-top: 20px;
    text-align: center;
}

.auth-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 14px;
}

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

/* Navbar */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand h2 {
    font-size: 20px;
    color: var(--text-primary);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-user span {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    min-height: calc(100vh - 65px);
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--surface);
    border-right: 1px solid var(--border-color);
    padding: 20px 0;
}

.nav-menu {
    list-style: none;
}

.nav-item {
    display: block;
    padding: 12px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

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

.nav-item.active {
    background: var(--background);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.content-page h1 {
    font-size: 32px;
    margin-bottom: 30px;
}

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

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    font-size: 40px;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Recent Campaigns */
.recent-campaigns {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

.recent-campaigns h2 {
    font-size: 20px;
    margin-bottom: 20px;
}

.campaigns-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.campaign-item {
    padding: 16px;
    background: var(--background);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.campaign-info h3 {
    font-size: 16px;
    margin-bottom: 4px;
}

.campaign-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.campaign-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-draft {
    background: #475569;
    color: #f1f5f9;
}

.status-sent {
    background: #065f46;
    color: #a7f3d0;
}

.status-sending {
    background: #1e40af;
    color: #bfdbfe;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

/* Content Cards */
.content-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

.content-card h2 {
    font-size: 20px;
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

/* Subscriber List */
.subscriber-item {
    padding: 16px;
    background: var(--background);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.subscriber-info {
    flex: 1;
}

.subscriber-email {
    font-weight: 500;
    color: var(--text-primary);
}

.subscriber-name {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.subscriber-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: var(--success-color);
    color: white;
}

.subscriber-lists {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.8;
}

.list-label {
    color: var(--text-secondary);
    font-weight: 500;
    margin-right: 6px;
}

.list-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    margin-right: 4px;
    margin-bottom: 2px;
}

.list-badge.newsletter {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.list-badge.source {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

/* Textarea */
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    background: var(--background);
    color: var(--text-primary);
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Modal */
.modal {
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.9);
    overflow: auto;
}

.modal-content {
    background-color: var(--surface);
    margin: 5% auto;
    padding: 30px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-close {
    color: var(--text-secondary);
    float: right;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 20px;
}

/* Email Preview */
.email-preview {
    background: #ffffff;
    color: #000000;
    padding: 20px;
    border-radius: 8px;
    font-family: Arial, sans-serif;
}

/* Image Upload */
.image-upload-area {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    background: var(--background);
    cursor: pointer;
    transition: all 0.3s;
}

.image-upload-area:hover {
    border-color: var(--primary-color);
    background: var(--surface);
}

.image-upload-area.dragover {
    border-color: var(--primary-color);
    background: var(--surface);
    transform: scale(1.02);
}

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

.upload-placeholder svg {
    margin: 0 auto 15px;
    color: var(--text-secondary);
}

.upload-placeholder p {
    margin: 10px 0 5px;
    font-size: 16px;
    color: var(--text-primary);
}

.upload-placeholder small {
    color: var(--text-secondary);
}

.image-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}

.btn-remove-image {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--error-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.btn-remove-image:hover {
    background: #dc2626;
}

.btn-delete {
    background: var(--error-color);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.btn-delete:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Crop Tool */
.crop-container {
    max-width: 100%;
    overflow: auto;
    background: var(--background);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

#crop-canvas {
    max-width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.crop-controls {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.crop-controls label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.crop-controls input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
}

.crop-controls input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.crop-controls input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

.crop-controls span {
    min-width: 60px;
    text-align: right;
    font-weight: 500;
}

/* Saved Campaign Item */
.saved-campaign-item {
    padding: 16px;
    background: var(--background);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.saved-campaign-info h3 {
    font-size: 16px;
    margin: 0 0 4px 0;
    color: var(--text-primary);
}

.saved-campaign-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.saved-campaign-actions {
    display: flex;
    gap: 8px;
}

/* Campaign Stats */
.campaign-stat-item {
    padding: 20px;
    background: var(--background);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 15px;
}

.campaign-stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.campaign-stat-header h3 {
    font-size: 18px;
    margin: 0;
    color: var(--text-primary);
}

.campaign-stat-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.stat-item {
    text-align: center;
    padding: 10px;
    background: var(--surface);
    border-radius: 6px;
}

.stat-item-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-item-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Active Campaigns */
.active-campaigns {
    margin-top: 40px;
}

.active-campaign-item {
    border-left: 4px solid var(--primary-color);
}

.active-campaign-item[data-status="paused"] {
    border-left-color: var(--warning-color, #f59e0b);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
    margin: 12px 0 6px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.campaign-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.campaign-actions .btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

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

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

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