/* ═══════════════════════════════════════════════════════════════════
   FreelanceFlow — Design System
   Responsive, unified, premium styling
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Root Variables ─────────────────────────────────────────────── */
:root {
    --ff-primary: #3b82f6;
    --ff-primary-dark: #2563eb;
    --ff-success: #10b981;
    --ff-warning: #f59e0b;
    --ff-danger: #ef4444;
    --ff-dark: #1e293b;
    --ff-darker: #0f172a;
    --ff-body-bg: #f4f7fa;
    --ff-text: #2b3445;
    --ff-text-muted: #64748b;
    --ff-border: rgba(0,0,0,0.06);
    --ff-radius: 12px;
    --ff-shadow: 0 4px 12px rgba(0,0,0,0.06);
    --ff-shadow-hover: 0 12px 24px rgba(0,0,0,0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--ff-body-bg) !important;
    color: var(--ff-text);
    -webkit-font-smoothing: antialiased;
}

/* ── Sidebar Layout & Nav ───────────────────────────────────────── */
body {
    overflow-x: hidden;
}

#wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

#sidebar-wrapper {
    min-height: 100vh;
    width: 70px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, var(--ff-dark), var(--ff-darker)) !important;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    white-space: nowrap;
    z-index: 1040;
}

#wrapper.toggled #sidebar-wrapper {
    width: 260px;
}

.sidebar-header-wrapper {
    display: flex;
    align-items: center;
    height: 70px;
    padding: 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

#sidebar-toggle {
    background: transparent;
    border: none;
    color: white;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 1.5rem;
    flex-shrink: 0;
}

#sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-logo-text {
    opacity: 0;
    transition: opacity 0.2s ease;
    visibility: hidden;
    font-size: 1.3rem;
    font-weight: bold;
    letter-spacing: -0.5px;
    color: white;
    text-decoration: none;
}

#wrapper.toggled .sidebar-logo-text {
    opacity: 1;
    visibility: visible;
    transition-delay: 0.1s;
}

#sidebar-wrapper .list-group-item {
    border: none;
    padding: 0;
    height: 56px;
    font-size: 0.95rem;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
}

#sidebar-wrapper .list-group-item i {
    width: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    margin: 0 !important;
}

.sidebar-link-text {
    opacity: 0;
    transition: opacity 0.2s ease;
    visibility: hidden;
}

#wrapper.toggled .sidebar-link-text {
    opacity: 1;
    visibility: visible;
    transition-delay: 0.1s;
}

#sidebar-wrapper .list-group-item:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #38bdf8 !important;
}

#wrapper.toggled #sidebar-wrapper .list-group-item:hover {
    padding-left: 10px;
}

#page-content-wrapper {
    min-width: 0;
    width: calc(100% - 70px);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#wrapper.toggled #page-content-wrapper {
    width: calc(100% - 260px);
}

.navbar {
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.nav-link {
    font-weight: 500;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--ff-primary) !important;
}

/* Sidebar Toggle Logic Media Queries */
@media (max-width: 991.98px) {
    #sidebar-wrapper {
        position: absolute;
        height: 100%;
        z-index: 1050;
    }
    #page-content-wrapper {
        margin-left: 70px;
        width: calc(100% - 70px);
    }
    #wrapper.toggled #page-content-wrapper {
        margin-left: 70px;
        width: calc(100% - 70px);
    }
}

@media (min-width: 992px) {
    #sidebar-wrapper {
        margin-left: 0;
    }
}

/* ── Card System ────────────────────────────────────────────────── */
.card {
    border-radius: var(--ff-radius);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    border: 1px solid var(--ff-border) !important;
}
.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--ff-shadow-hover) !important;
}
/* Disable hover lift on panels that shouldn't float */
.card.no-hover:hover,
.ai-panel:hover,
.card-header + .card-body:hover {
    transform: none;
}
.card-header {
    border-top-left-radius: var(--ff-radius) !important;
    border-top-right-radius: var(--ff-radius) !important;
    border-bottom: none !important;
}

/* ── Gradient Backgrounds ───────────────────────────────────────── */
.bg-primary   { background: linear-gradient(135deg, #3b82f6, #2563eb) !important; }
.bg-success   { background: linear-gradient(135deg, #10b981, #059669) !important; }
.bg-warning   { background: linear-gradient(135deg, #f59e0b, #d97706) !important; }
.bg-danger    { background: linear-gradient(135deg, #ef4444, #dc2626) !important; }
.bg-dark      { background: linear-gradient(135deg, #334155, #1e293b) !important; }
.bg-info      { background: linear-gradient(135deg, #06b6d4, #0891b2) !important; }

/* ── Form & Button ──────────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: 8px;
    padding: 0.6rem 1rem;
    border: 1px solid #cbd5e1;
    font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--ff-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}
.btn {
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: all 0.2s ease;
}
.btn:active {
    transform: scale(0.97);
}

/* ── Utilities ──────────────────────────────────────────────────── */
.letter-spacing { letter-spacing: 1px; }
.alert {
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

/* ═══════════════════════════════════════════════════════════════════
   AI-GENERATED TEXT FORMATTING
   Ensures all ChatGPT output renders beautifully
   ═══════════════════════════════════════════════════════════════════ */

.ai-content {
    line-height: 1.85;
    font-size: 0.93rem;
    color: #334155;
    text-align: justify;
    word-break: break-word;
}

/* Section headers from AI (bold text at line start) */
.ai-content strong {
    color: #1e293b;
    font-weight: 700;
}

/* Numbered lists from AI */
.ai-content br + br {
    display: block;
    content: "";
    margin-top: 0.3rem;
}

/* Emoji icon alignment */
.ai-content strong::first-letter {
    font-size: 1em;
}

/* ── AI Panel Skeleton (loading state) ──────────────────────────── */
.ai-skeleton {
    padding: 1.5rem;
}
.ai-skeleton .skeleton-line {
    height: 14px;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
    margin-bottom: 12px;
}
.ai-skeleton .skeleton-line:nth-child(1) { width: 70%; }
.ai-skeleton .skeleton-line:nth-child(2) { width: 100%; }
.ai-skeleton .skeleton-line:nth-child(3) { width: 85%; }
.ai-skeleton .skeleton-line:nth-child(4) { width: 60%; height: 12px; }
.ai-skeleton .skeleton-line:nth-child(5) { width: 92%; }
.ai-skeleton .skeleton-line:nth-child(6) { width: 78%; }

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Pulse animation for "Generating..." text */
.ai-generating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ff-text-muted);
    font-weight: 500;
    font-size: 0.85rem;
    padding: 1rem 1.5rem;
}
.ai-generating .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   Mobile-first approach
   ═══════════════════════════════════════════════════════════════════ */

/* ── Container padding on mobile ────────────────────────────────── */
@media (max-width: 575.98px) {
    main.container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    h2 { font-size: 1.4rem; }
    h4 { font-size: 1.15rem; }
    h5 { font-size: 1rem; }
    .display-6 { font-size: 1.8rem; }
}

/* ── Dashboard metrics: 2 cols on tablet, 1 on mobile ───────────── */
@media (max-width: 767.98px) {
    .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    /* AI panels: full width and left-aligned */
    .ai-content {
        text-align: left;
        font-size: 0.88rem;
    }
    /* Reduce card padding on mobile */
    .card-body {
        padding: 1rem !important;
    }
}

@media (max-width: 575.98px) {
    .col-md-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ── Profile snapshot: stack on mobile ───────────────────────────── */
@media (max-width: 767.98px) {
    .card-body.d-flex.flex-wrap {
        flex-direction: column;
        align-items: flex-start !important;
    }
    .d-flex.flex-wrap.align-items-center.gap-3 {
        margin-top: 0.75rem;
    }
    /* Badge wrapping */
    .badge {
        font-size: 0.75rem !important;
    }
}

/* ── Chart and activity: stack on tablet ─────────────────────────── */
@media (max-width: 767.98px) {
    .col-md-7, .col-md-5 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ── Project cards: 2 cols on tablet, 1 on mobile ───────────────── */
@media (max-width: 767.98px) {
    .col-lg-4.col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ── Marketplace: stack form+results on mobile ──────────────────── */
@media (max-width: 991.98px) {
    .col-lg-5, .col-lg-7 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    /* Unstick the form on mobile so it doesn't cover content */
    .sticky-top {
        position: relative !important;
        top: auto !important;
    }
}

/* ── Score gauge: scale down on small screens ───────────────────── */
@media (max-width: 575.98px) {
    svg[viewBox="0 0 120 120"] {
        width: 90px;
        height: 90px;
    }
}

/* ── Payment table: responsive ──────────────────────────────────── */
@media (max-width: 767.98px) {
    .table {
        font-size: 0.8rem;
    }
    .table td, .table th {
        padding: 0.5rem 0.4rem;
    }
}

/* ── Client cards: 1 col on mobile ──────────────────────────────── */
@media (max-width: 575.98px) {
    .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ── AI Insights panels: stack on mobile ─────────────────────────── */
@media (max-width: 767.98px) {
    .col-md-6.mb-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ── Footer ─────────────────────────────────────────────────────── */
footer {
    font-size: 0.85rem;
}

/* ═══════════════════════════════════════════════════════════════════
   PRINT-FRIENDLY (for AI reports)
   ═══════════════════════════════════════════════════════════════════ */
@media print {
    .navbar, .btn, footer, .modal { display: none !important; }
    .card { break-inside: avoid; box-shadow: none !important; border: 1px solid #ddd !important; }
    .ai-content { text-align: left; }
}
