/**
 * LeadPad - Main Stylesheet
 *
 * This file contains all styles for the LeadPad application including:
 * - CSS Variables for theming (light/dark mode)
 * - Base styles and resets
 * - Component styles (buttons, forms, modals, tables)
 * - Toggle switch component
 * - Responsive styles
 *
 * TODO: Consider splitting into separate files for larger projects
 * TODO: Add CSS minification for production
 */

/* ============================================
   CSS Variables - Theme Configuration
   ============================================ */
:root {
    /* Light theme (default) */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8f9fa;
    --text-primary: #333333;
    --text-secondary: #555555;
    --text-muted: #666666;
    --border-color: #dddddd;
    --border-light: #e9ecef;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-heavy: rgba(0, 0, 0, 0.2);
    --accent-color: #007bff;
    --accent-hover: #0056b3;
    --accent-light: #66b3ff;
    --success-color: #28a745;
    --success-bg: #d4edda;
    --success-text: #155724;
    --danger-color: #dc3545;
    --danger-hover: #c82333;
    --danger-bg: #f8d7da;
    --danger-text: #721c24;
    --warning-bg: #fff3cd;
    --warning-text: #856404;
}

/* Dark theme */
[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #e8e8e8;
    --text-secondary: #b8b8b8;
    --text-muted: #888888;
    --border-color: #3a3a5c;
    --border-light: #2a2a4c;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-heavy: rgba(0, 0, 0, 0.5);
    --accent-color: #4dabf7;
    --accent-hover: #74c0fc;
    --accent-light: #339af0;
    --success-color: #51cf66;
    --success-bg: #1e3a2f;
    --success-text: #8ce99a;
    --danger-color: #ff6b6b;
    --danger-hover: #fa5252;
    --danger-bg: #3a1e1e;
    --danger-text: #ffa8a8;
    --warning-bg: #3a3520;
    --warning-text: #ffe066;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* General link styles with hover effects */
a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
}

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

/* Table links - inherit color but add hover */
table a {
    color: var(--accent-color);
    font-weight: 500;
}

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

/* ============================================
   Layout Components
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.auth-box {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-color);
    width: 100%;
    max-width: 400px;
}

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

/* ============================================
   Form Components
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color 0.3s, background-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* ============================================
   Button Components
   ============================================ */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s;
    text-decoration: none;
}

/* Ensure buttons never get link hover styles */
.btn:hover {
    text-decoration: none;
}

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

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

/* Full width button modifier */
.btn-block {
    width: 100%;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

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

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

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

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Extra small button for tight spaces */
.btn-xs {
    padding: 4px 8px;
    font-size: 11px;
}

/* ============================================
   Toggle Switch Component (Bootstrap-like)
   TODO: Add disabled state styling
   TODO: Add size variants (sm, lg)
   ============================================ */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    margin-bottom: 15px;
}

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

.toggle-slider {
    position: relative;
    width: 50px;
    height: 26px;
    background-color: var(--border-color);
    border-radius: 26px;
    transition: background-color 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px var(--shadow-color);
}

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

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

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.toggle-label {
    margin-left: 10px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Toggle switch for theme (special styling) */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle .toggle-switch {
    margin-bottom: 0;
}

.theme-toggle .toggle-slider {
    width: 44px;
    height: 24px;
}

.theme-toggle .toggle-slider::before {
    width: 18px;
    height: 18px;
}

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

.theme-icon {
    font-size: 16px;
}

.auth-toggle {
    text-align: center;
    margin-top: 20px;
    color: var(--text-muted);
}

.auth-toggle a {
    color: var(--accent-color);
    text-decoration: none;
}

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

/* ============================================
   Alert Components
   ============================================ */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-error {
    background-color: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-color);
}

.alert-success {
    background-color: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-color);
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
    display: none !important;
}

/* ============================================
   Header Component
   TODO: Add mobile responsive hamburger menu
   ============================================ */
.header {
    background: var(--bg-secondary);
    padding: 15px 0;
    box-shadow: 0 2px 4px var(--shadow-color);
    margin-bottom: 30px;
    transition: background-color 0.3s ease;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 24px;
    color: var(--accent-color);
    font-weight: 700;
}

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

/* Navigation links with pill-style design */
.header nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.header nav a:hover {
    color: var(--accent-color);
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    text-decoration: none;
}

.header nav a.active {
    color: white;
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.header nav a.active:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* Separator between nav sections */
.nav-separator {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
    margin: 0 8px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    font-size: 13px;
}

.user-info #userName {
    color: var(--text-primary);
    font-weight: 500;
}

.user-badge {
    background: var(--border-light);
    color: var(--text-secondary);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
}

.user-badge.admin {
    background: var(--success-color);
    color: white;
}

/* ============================================
   Dashboard Card Component
   ============================================ */
.dashboard-card {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-color);
    transition: background-color 0.3s ease;
}

.dashboard-card h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* ============================================
   Table Component
   TODO: Add sortable columns
   TODO: Add pagination styling
   ============================================ */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}

tbody tr {
    transition: background-color 0.15s ease;
}

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

.actions {
    display: flex;
    gap: 8px;
}

/* ============================================
   Modal Component
   TODO: Add animation for open/close
   TODO: Add backdrop click to close option
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--shadow-heavy);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    color: var(--text-primary);
}

.modal h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ============================================
   Loading State
   ============================================ */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}
