/* PlanningCore - Main Stylesheet */

/* ============================================================================
   RESET & BASE
   ============================================================================ */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --text: #1e293b;
    --text-muted: #64748b;
    --bg: #ffffff;
    --bg-secondary: #f8fafc;
    --border: #e2e8f0;
    --border-dark: #cbd5e1;
    
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --radius: 8px;
    --radius-sm: 4px;
}

html {
    font-size: 16px;
    line-height: 1.5;
}

body {
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg-secondary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
    margin-bottom: 0.75rem;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

.h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; }
.h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.75rem; }

p {
    margin-bottom: 1rem;
}

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

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

.muted {
    color: var(--text-muted);
    font-size: 0.875rem;
}

strong {
    font-weight: 600;
}

/* ============================================================================
   LAYOUT
   ============================================================================ */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

main.container {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 2rem;
}

.content {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    min-height: 400px;
}

/* ============================================================================
   NAVIGATION
   ============================================================================ */

.navbar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.nav-brand a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text);
    padding: 8px 12px;
    min-width: 44px;
    min-height: 44px;
}

.nav-links {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    flex-wrap: wrap;
}

@media (max-width: 900px) {
    .nav-toggle { display: block; }
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        padding: 16px 20px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        box-shadow: 0 4px 16px rgba(0,0,0,0.08);
        z-index: 99;
    }
    .nav-links.open { display: flex; }
    .nav-links a { width: 100%; padding: 8px 0; }
    .navbar .container { position: relative; }
    .nav-tools-dropdown .nav-mega-dropdown { position: fixed; top: auto; left: 8px; right: 8px; width: auto; }
}

.nav-links a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--primary);
    text-decoration: none;
}

/* ============================================================================
   FOOTER
   ============================================================================ */

.footer {
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    margin-top: auto;
    text-align: center;
}

.footer p {
    margin: 0;
}

/* ============================================================================
   GRID
   ============================================================================ */

.grid {
    display: grid;
    gap: 1.5rem;
}

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

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   CARDS
   ============================================================================ */

.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* ============================================================================
   FORMS
   ============================================================================ */

.form-group {
    margin-bottom: 1rem;
}

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

.required {
    color: var(--error);
}

.input, .textarea, select {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus, .textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
    text-align: center;
}

.btn:hover {
    background: var(--primary-dark);
    text-decoration: none;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

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

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

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

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

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

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* ============================================================================
   BADGES
   ============================================================================ */

.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-success {
    background: #d1fae5;
    border-color: var(--success);
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    border-color: var(--warning);
    color: #92400e;
}

.badge-error {
    background: #fee2e2;
    border-color: var(--error);
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    border-color: var(--primary);
    color: #1e3a8a;
}

/* ============================================================================
   ALERTS
   ============================================================================ */

.alert {
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    border: 1px solid;
}

.alert-success {
    background: #d1fae5;
    border-color: var(--success);
    color: #065f46;
}

.alert-error {
    background: #fee2e2;
    border-color: var(--error);
    color: #991b1b;
}

.alert-warning {
    background: #fef3c7;
    border-color: var(--warning);
    color: #92400e;
}

.alert-info {
    background: #dbeafe;
    border-color: var(--primary);
    color: #1e3a8a;
}

/* ============================================================================
   TABLES
   ============================================================================ */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table thead {
    background: var(--bg-secondary);
}

.table th {
    text-align: left;
    padding: 0.75rem;
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--border);
}

.table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

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

/* ============================================================================
   PROGRESS
   ============================================================================ */

.progress {
    position: relative;
    height: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

.progress-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
}

/* ============================================================================
   UTILITIES
   ============================================================================ */

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

.text-right {
    text-align: right;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.hidden {
    display: none;
}

/* ============================================================================
   RESPONSIVE — Base mobile adjustments (375px-768px)
   ============================================================================ */

@media (max-width: 768px) {
    /* Cards reduce padding */
    .card { padding: 1rem; }
    .card-title { font-size: 1.1rem; }

    /* Buttons: ensure touch targets */
    .btn { padding: 0.75rem 1.25rem; }
    .btn-small { padding: 0.5rem 0.75rem; min-height: 44px; }

    /* Badges */
    .badge { font-size: 0.7rem; padding: 0.2rem 0.5rem; }

    /* Table: scrollable on mobile */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table th, .table td { padding: 0.5rem; font-size: 0.8rem; white-space: nowrap; }
}

@media (max-width: 480px) {
    .card { padding: 0.75rem; }
    .btn { font-size: 0.9rem; }
}
