/* Mobile-First Styles for Affiliate Dashboard PWA */

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

:root {
    --primary-color: #4A90E2;
    --primary-dark: #3A7BC8;
    --success-color: #4CAF50;
    --danger-color: #F44336;
    --warning-color: #FF9800;
    --text-primary: #212121;
    --text-secondary: #757575;
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F5;
    --border-color: #E0E0E0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Debug Toggle Button */
.debug-toggle {
    position: fixed;
    bottom: 90px;
    right: 16px;
    width: 48px;
    height: 48px;
    font-size: 24px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 9998;
    transition: transform 0.2s;
}

.debug-toggle:active {
    transform: scale(0.95);
}

/* Error Console */
.error-console {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

.error-console.hidden {
    display: none;
}

.error-console-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
}

.error-console-header span {
    flex: 1;
    font-weight: bold;
    color: #fff;
}

.btn-copy, .btn-clear, .btn-close {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

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

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

.btn-close {
    background: var(--danger-color);
    color: white;
    font-size: 20px;
    padding: 4px 10px;
}

.error-console-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    font-size: 11px;
    line-height: 1.6;
}

.log-entry {
    margin-bottom: 8px;
    padding: 8px;
    border-left: 3px solid #666;
    background: rgba(255, 255, 255, 0.05);
}

.log-entry.error {
    border-left-color: var(--danger-color);
    color: #ff6b6b;
}

.log-entry.warn {
    border-left-color: var(--warning-color);
    color: #ffa500;
}

.log-entry.info {
    border-left-color: var(--primary-color);
    color: #6bb6ff;
}

.log-entry.success {
    border-left-color: var(--success-color);
    color: #90ee90;
}

.log-timestamp {
    color: #888;
    font-size: 10px;
    margin-right: 8px;
}

/* Loader */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loader.hidden {
    display: none;
}

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

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

/* Screens */
.screen {
    min-height: 100vh;
}

.screen.hidden {
    display: none;
}

/* Login Screen */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.login-container {
    width: 100%;
    max-width: 400px;
    background: var(--bg-primary);
    border-radius: 16px;
    padding: 32px 24px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.logo p {
    font-size: 14px;
    color: var(--text-secondary);
}

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

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

.form-group input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

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

.error-message {
    margin-top: 16px;
    padding: 12px;
    font-size: 14px;
    color: var(--danger-color);
    background: rgba(244, 67, 54, 0.1);
    border-radius: 8px;
    display: none;
}

.error-message.show {
    display: block;
}

/* Main App */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Navigation */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.nav-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
}

.nav-content h2 {
    font-size: 20px;
    font-weight: 600;
}

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
}

/* Content */
.content {
    flex: 1;
    margin-top: 64px;
    margin-bottom: 72px;
    padding: 16px;
    overflow-y: auto;
}

.view.hidden {
    display: none;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.card-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

/* Section Header */
.section-header {
    margin-bottom: 16px;
}

.section-header h3 {
    font-size: 18px;
    font-weight: 600;
}

/* Campaign List */
.campaign-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.campaign-card {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.campaign-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.campaign-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
}

.campaign-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.campaign-status {
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
}

.campaign-status.active {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
}

.campaign-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.stat {
    flex: 1;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
}

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

.progress-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

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

/* Campaign Detail */
.btn-back {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-color);
    background: none;
    border: none;
    cursor: pointer;
    margin-bottom: 16px;
}

.detail-card {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.detail-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.detail-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    display: flex;
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item svg {
    margin-bottom: 4px;
}

.nav-item span {
    font-size: 11px;
    font-weight: 500;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 16px;
    color: var(--text-secondary);
}

/* Responsive */
@media (min-width: 768px) {
    .summary-cards {
        grid-template-columns: repeat(4, 1fr);
    }
}
