/**
 * PayPerRoute v5 — Custom Application Styles
 * Extends Pico.css with mobile-first enhancements.
 */

/* === Status Colors === */
.status-active, .status-paid, .status-completed, .status-approved {
    color: #2e7d32;
    background-color: #e8f5e9;
}
.status-pending, .status-in_progress, .status-in-progress,
.status-sent, .status-viewed, .status-needs_attention {
    color: #f57f17;
    background-color: #fff8e1;
}
.status-overdue, .status-failed, .status-delinquent, .status-error, .status-declined {
    color: #c62828;
    background-color: #ffebee;
}
.status-inactive, .status-on_hold, .status-on-hold, .status-archived, .status-void {
    color: #616161;
    background-color: #f5f5f5;
}

/* === Status Badges === */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* === Mobile Touch Targets === */
button, [role="button"], a.button,
input[type="submit"], input[type="button"],
select, .touch-target {
    min-height: 44px;
    min-width: 44px;
}

/* === Form inputs — prevent iOS zoom === */
input, select, textarea {
    font-size: 16px !important;
}

/* === Navigation hamburger — hidden by default (desktop) === */
.nav-toggle {
    display: none;
}

/* === Navigation — Mobile === */
@media (max-width: 768px) {
    nav.container {
        flex-wrap: wrap;
    }
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        padding: 0.4rem 0.75rem;
        font-size: 1rem;
        font-weight: 500;
        background: var(--pico-primary);
        color: var(--pico-primary-inverse);
        border: 1px solid var(--pico-primary);
        border-radius: var(--pico-border-radius);
        cursor: pointer;
    }
    .nav-toggle:hover,
    .nav-toggle:focus {
        background: var(--pico-primary-hover);
        border-color: var(--pico-primary-hover);
    }
    .nav-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        flex-basis: 100%;
        margin: 0;
        padding: 0;
    }
    .nav-menu.nav-open {
        display: flex;
    }
    .nav-menu li {
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--pico-muted-border-color);
    }
    .nav-menu li:last-child {
        border-bottom: none;
    }
}

/* === Single Column Mobile === */
@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr !important;
    }
}

/* === Flash/Toast Notifications === */
.flash {
    border-radius: 8px;
    padding: 1rem 1.5rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.flash-success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}
.flash-error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}
.flash-warning {
    background-color: #fff8e1;
    color: #f57f17;
    border: 1px solid #ffe082;
}
.flash-info {
    background-color: #e3f2fd;
    color: #1565c0;
    border: 1px solid #90caf9;
}

/* === Demo Data Badge === */
.demo-badge {
    display: inline-block;
    background: #fff3e0;
    color: #e65100;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-left: 0.3rem;
}

/* === Thumb Zone — Primary Action Buttons === */
.btn-primary-action {
    position: fixed;
    bottom: 2rem;
    right: 1.5rem;
    z-index: 100;
    min-height: 56px;
    min-width: 56px;
    border-radius: 28px;
    font-size: 1.1rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* === Kanban Board === */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}
.kanban-col,
.kanban-column {
    min-width: 280px;
    flex: 1;
    background: var(--pico-card-background-color);
    border-radius: 8px;
    padding: 1rem;
}
.kanban-card {
    background: var(--pico-background-color);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: grab;
}
.kanban-card:active {
    cursor: grabbing;
}

/* === Stat Cards Grid === */
.stat-card {
    text-align: center;
    padding: 1.5rem;
}
.stat-card h3 {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}
.stat-card h3 a {
    color: inherit;
    text-decoration: none;
}
.stat-card h3 a:hover {
    text-decoration: underline;
    opacity: 0.85;
}

/* === Search Results Dropdown === */
#search-results {
    position: relative;
    z-index: 50;
}
#search-results ul {
    position: absolute;
    width: 100%;
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 400px;
    overflow-y: auto;
}

/* === Job Roster Cards === */
.job-card {
    border-left: 4px solid var(--pico-primary);
    margin-bottom: 1rem;
    padding: 1rem;
}
.job-card.completed {
    border-left-color: #2e7d32;
    opacity: 0.7;
}
.job-card.skipped {
    border-left-color: #c62828;
}

/* === HTMX Loading Indicator === */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline-block;
}

/* === Table Horizontal Scroll Wrapper === */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* === Invoice Actions Cell === */
.invoice-actions {
    white-space: nowrap;
}
@media (max-width: 768px) {
    .invoice-actions {
        white-space: normal;
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
        padding: 0.75rem 0.5rem;
    }
    .invoice-actions form,
    .invoice-actions > a,
    .invoice-actions > button {
        display: inline-flex;
    }
    .invoice-actions button,
    .invoice-actions a[role="button"],
    .invoice-actions a.outline {
        min-height: 40px;
    }
}

/* === Invoice / Quote Line Item Rows === */
.invoice-item-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 0.5rem 0;
}
@media (max-width: 600px) {
    .invoice-item-row {
        flex-direction: column;
        align-items: stretch;
    }
    .invoice-item-row > * {
        width: 100%;
        flex: 1 1 auto !important;
    }
    .quote-item {
        grid-template-columns: 1fr !important;
    }
    .quote-item > * {
        width: 100%;
    }
}

/* === Leads Kanban 4-column grid === */
.kanban-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    align-items: start;
}
@media (max-width: 900px) {
    .kanban-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 600px) {
    .kanban-4 {
        grid-template-columns: 1fr;
    }
}

/* === Sidebar layout (Price Book etc.) === */
.layout-sidebar {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
    align-items: start;
}
@media (max-width: 800px) {
    .layout-sidebar {
        grid-template-columns: 1fr;
    }
}

/* === Banner row (stacks on mobile) === */
.banner-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
@media (max-width: 600px) {
    .banner-row {
        flex-direction: column;
        align-items: stretch;
    }
    .banner-row > * {
        width: 100%;
    }
}

/* === Extra mobile nav tweaks === */
@media (max-width: 768px) {
    .nav-toggle {
        margin-left: auto;
    }
}
@media (max-width: 480px) {
    nav a[role="button"] {
        padding: 0.5rem 0.6rem;
        min-height: 44px;
        font-size: 0.85rem;
    }
}
