/**
 * Common Styles - Landing Page Generator
 * Dark Theme Design System
 */

/* ========== CSS Variables ========== */
:root {
    /* Primary Colors */
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-dark: #4f46e5;

    /* Accent */
    --accent: #22d3ee;
    --accent-hover: #67e8f9;

    /* Status Colors */
    --success: #10b981;
    --success-dark: #059669;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --warning: #f59e0b;

    /* Dark Backgrounds */
    --bg-darkest: #0f0f1a;
    --bg-dark: #1a1a2e;
    --bg-card: #252542;
    --bg-input: #1e1e38;
    --bg-hover: #2d2d4a;

    /* Text Colors */
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Borders */
    --border: #2d2d4a;
    --border-light: #3d3d5c;
    --border-focus: #6366f1;

    /* Shadows */
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.5);
    --shadow-glow: rgba(99, 102, 241, 0.3);

    /* Gradients */
    --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-accent: linear-gradient(135deg, #06b6d4 0%, #6366f1 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-dark: linear-gradient(135deg, #1a1a2e 0%, #252542 100%);

    /* Spacing */
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Typography */
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Poppins', var(--font);
}

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

body {
    font-family: var(--font);
    background: var(--bg-dark);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========== Page Loader ========== */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.page-loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.page-loader-icon {
    color: var(--primary);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

.page-loader-text {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

@keyframes pulse-glow {
    0%, 100% {
        opacity: 1;
        filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.5));
    }
    50% {
        opacity: 0.6;
        filter: drop-shadow(0 0 16px rgba(99, 102, 241, 0.8));
    }
}

.page-content {
    transition: opacity 0.3s ease;
}

.page-content.visible {
    opacity: 1 !important;
}

/* ========== Typography ========== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text);
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

p {
    color: var(--text-secondary);
}

a {
    color: var(--primary-hover);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent);
    text-decoration: none;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--gradient);
    color: white;
    box-shadow: 0 4px 15px var(--shadow-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px var(--shadow-glow);
}

.btn-secondary {
    background: transparent;
    color: var(--primary-hover);
    border: 2px solid var(--primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--border-light);
}

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

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

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

.btn-danger:hover:not(:disabled) {
    background: var(--danger-dark);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-full {
    width: 100%;
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
    border: 0;
    border-radius: var(--radius);
}

.btn-icon {
    padding: 10px;
    min-width: 40px;
}

/* ========== Forms ========== */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

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

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    color: var(--text);
    transition: all 0.2s;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--shadow-glow);
}

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

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.field-error {
    display: block;
    font-size: 12px;
    color: var(--danger);
    margin-top: 6px;
    min-height: 18px;
}

.form-control.input-error {
    border-color: var(--danger);
}

.form-control.input-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.form-control.input-valid {
    border-color: var(--success);
}

.form-control.input-valid:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

textarea.form-control {
    resize: vertical;
    min-height: 160px;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    padding-right: 40px;
}

select.form-control option {
    background: var(--bg-card);
    color: var(--text);
}

/* ========== Cards ========== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.card-header {
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    margin-bottom: 4px;
}

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

/* ========== Loading States ========== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
}

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

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
    margin-bottom: 0;
}

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

/* Spin animation for inline SVG icons */
.spin {
    animation: spin 1s linear infinite;
}

/* ========== Alerts & Messages ========== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border: 1px solid transparent;
}

.alert svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 1px;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

.alert-info {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
    color: var(--primary-hover);
}

/* ========== Header ========== */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo svg {
    width: 24px;
    height: 24px;
    color: var(--primary-hover);
}

.logo:hover {
    text-decoration: none;
    color: var(--text);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text);
    text-decoration: none;
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

/* ========== Status Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge svg {
    width: 14px;
    height: 14px;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.badge-info {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-hover);
}

.badge-neutral {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

/* ========== Tables ========== */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr {
    transition: background 0.2s;
}

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

/* ========== Modals ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Blogger Instructions List */
.blogger-instructions {
    margin: 16px 0;
    padding-left: 24px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.blogger-instructions li {
    margin-bottom: 8px;
}

.blogger-instructions a {
    color: var(--primary);
}

.blogger-instructions a:hover {
    text-decoration: underline;
}

.blogger-instructions strong {
    color: var(--text);
}

.modal-body .alert {
    margin-top: 16px;
    margin-bottom: 0;
}

/* ========== Auth Pages (Login/Verify) ========== */
.auth-page {
    background: var(--bg-darkest);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

.auth-page::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 30% 30%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 70% 70%, rgba(34, 211, 238, 0.08) 0%, transparent 50%);
    pointer-events: none;
}

.auth-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 40px;
    border-radius: var(--radius-xl);
    max-width: 420px;
    width: 100%;
    text-align: center;
    position: relative;
    z-index: 1;
}

.auth-icon {
    width: 60px;
    height: 60px;
    background: var(--gradient);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.auth-icon svg {
    width: 32px;
    height: 32px;
    color: white;
}

.auth-title {
    font-size: 24px;
    margin-bottom: 8px;
    font-family: var(--font-heading);
}

.auth-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 14px;
    line-height: 1.6;
}

/* ========== Icon Utilities ========== */
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-sm svg { width: 16px; height: 16px; }
.icon-md svg { width: 20px; height: 20px; }
.icon-lg svg { width: 24px; height: 24px; }
.icon-xl svg { width: 32px; height: 32px; }

/* ========== Utilities ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--primary-hover); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

.hidden { display: none !important; }
.show { display: block !important; }

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

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

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

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

/* ========== Selection ========== */
::selection {
    background: var(--primary);
    color: white;
}

/* ========== Focus Visible ========== */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 12px;
        padding: 12px 20px;
        height: auto;
        min-height: 100px;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
    }

    .card {
        padding: 20px;
    }

    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.375rem; }
}

@media (max-width: 480px) {
    .auth-container {
        padding: 32px 24px;
    }

    .btn {
        padding: 10px 20px;
    }

    h1 { font-size: 1.5rem; }
}

/* ========== Toast Notifications ========== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px var(--shadow-lg);
    min-width: 300px;
    max-width: 450px;
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease-out;
}

.toast.toast-hiding {
    animation: toastSlideOut 0.3s ease-out forwards;
}

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

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

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-icon svg {
    width: 20px;
    height: 20px;
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-message {
    color: var(--text);
    font-size: 0.9375rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.toast-close:hover {
    color: var(--text);
    background: var(--bg-hover);
}

/* Toast Types */
.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-error .toast-icon {
    color: var(--danger);
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-info {
    border-left: 4px solid var(--primary);
}

.toast-info .toast-icon {
    color: var(--primary);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-warning .toast-icon {
    color: var(--warning);
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: 0;
        max-width: 100%;
    }
}
