/* ORC - Mobile-First Styles */
:root {
    --primary: #2563eb;
    --primary-rgb: 37, 99, 235;
    --touch-min: 48px;
    --bottom-nav-h: 64px;
    --sidebar-w: 260px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #f1f5f9;
    min-height: 100vh;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Touch-friendly */
.btn, .form-control, .form-select, .nav-link, .bottom-nav a {
    min-height: var(--touch-min);
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
    background-color: color-mix(in srgb, var(--primary) 85%, black);
    border-color: color-mix(in srgb, var(--primary) 85%, black);
}
.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover {
    background-color: var(--primary);
    border-color: var(--primary);
}
.text-primary { color: var(--primary) !important; }
.bg-primary-custom { background-color: var(--primary) !important; }
.border-primary-custom { border-color: var(--primary) !important; }

/* Brand */
.brand-text {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--primary);
}

/* App layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    display: none;
    width: var(--sidebar-w);
    background: #fff;
    border-right: 1px solid #e2e8f0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    overflow-y: auto;
}

.app-main {
    flex: 1;
    width: 100%;
    padding-bottom: calc(var(--bottom-nav-h) + 16px);
}

.app-content {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Bottom nav - mobile */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-h);
    background: #fff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1050;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #64748b;
    font-size: 0.65rem;
    padding: 0.25rem 0.5rem;
    flex: 1;
    gap: 2px;
}

.bottom-nav a i {
    font-size: 1.25rem;
}

.bottom-nav a.active {
    color: var(--primary);
    font-weight: 600;
}

/* Responsive tables -> cards */
@media (max-width: 767.98px) {
    .table-responsive-cards thead { display: none; }
    .table-responsive-cards tbody tr {
        display: block;
        background: #fff;
        border-radius: 12px;
        margin-bottom: 0.75rem;
        padding: 1rem;
        box-shadow: 0 1px 3px rgba(0,0,0,.08);
        border: 1px solid #e2e8f0;
    }
    .table-responsive-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.35rem 0;
        border: none;
        text-align: right;
    }
    .table-responsive-cards tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        font-size: 0.8rem;
        text-align: left;
        margin-right: 1rem;
    }
    .table-responsive-cards tbody td.actions-cell {
        justify-content: flex-end;
        padding-top: 0.75rem;
        margin-top: 0.5rem;
        border-top: 1px solid #f1f5f9;
    }
    .table-responsive-cards tbody td.actions-cell::before { display: none; }
}

/* Tablet+ */
@media (min-width: 768px) {
    .app-sidebar { display: block; }
    .app-main {
        margin-left: var(--sidebar-w);
        padding-bottom: 0;
    }
    .bottom-nav { display: none; }
    .app-content { padding: 1.5rem 2rem; }
}

/* Status badges */
.badge-status { font-size: 0.75rem; padding: 0.4em 0.8em; }

/* Cards */
.stat-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    transition: transform .15s;
}
.stat-card:hover { transform: translateY(-2px); }

/* Timeline */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
    content: '';
    position: absolute;
    left: 0.55rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e2e8f0;
}
.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.55rem;
    top: 0.25rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #cbd5e1;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #e2e8f0;
}
.timeline-item.active::before {
    background: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}
.timeline-item.done::before {
    background: #22c55e;
    box-shadow: 0 0 0 2px #22c55e;
}

/* Landing */
.hero-gradient {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #3b82f6 100%);
}
.feature-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.landing-hero-card .landing-stat {
    padding: 0.5rem;
}

.landing-flow-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary, #2563eb);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
}

.landing-checklist li {
    padding: 0.35rem 0;
}

.landing-checklist li i.bi-check2 {
    color: var(--primary, #2563eb);
}

.admin-sidebar {
    width: 240px;
    min-height: 100vh;
}

@media (max-width: 767.98px) {
    .admin-shell { flex-direction: column; }
    .admin-sidebar { width: 100%; min-height: auto; }
}

/* Form improvements mobile */
.form-floating > .form-control,
.form-floating > .form-select {
    min-height: var(--touch-min);
}

/* Floating action button */
.fab {
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    z-index: 1040;
}

@media (min-width: 768px) {
    .fab {
        bottom: 24px;
        right: 24px;
    }
}

/* Print hide */
@media print {
    .bottom-nav, .app-sidebar, .fab, .no-print { display: none !important; }
}

/* Cliente autocomplete */
.cliente-search-wrap {
    position: relative;
}

.cliente-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1050;
    max-height: 280px;
    overflow-y: auto;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
}

.cliente-dropdown-item {
    border: none;
    border-bottom: 1px solid #f1f5f9;
    padding: 0.75rem 1rem;
    text-align: left;
}

.cliente-dropdown-item:last-child {
    border-bottom: none;
}

.pdf-preview-frame {
    width: 100%;
    height: min(75vh, 820px);
    border: 0;
    background: #fff;
}

@media (max-width: 767px) {
    .pdf-preview-frame {
        height: 65vh;
    }
}

.produto-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1050;
    max-height: 280px;
    overflow-y: auto;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
}

.produto-dropdown-item {
    border: none;
    border-bottom: 1px solid #f1f5f9;
    padding: 0.75rem 1rem;
    text-align: left;
}

.produto-dropdown-item:last-child {
    border-bottom: none;
}

.produto-picker.produto-selected [data-produto-search] {
    border-color: #22c55e;
    background-color: #f0fdf4;
}

.cliente-picker.cliente-selected [name="cliente_nome"] {
    border-color: #22c55e;
    background-color: #f0fdf4;
}

.midia-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.midia-item {
    position: relative;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #f8fafc;
    aspect-ratio: 1;
    border: 1px solid #e2e8f0;
}

.midia-item img,
.midia-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.midia-item a {
    display: block;
    width: 100%;
    height: 100%;
}

.midia-remove {
    position: absolute;
    top: 6px;
    right: 6px;
}

.midia-remove .btn {
    width: 28px;
    height: 28px;
    padding: 0;
    line-height: 1;
    border-radius: 50%;
}

