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

/* =================================================================
 * PALETA DE CORES OFICIAL ACAMONPLACE
 * Primary: #ff8701 (Laranja Acamon)
 * Charcoal/Dark: #363f48 / #171d24
 * Accent Blue: #3566bb
 * Accent Green: #61a229
 * ================================================================= */

:root {
    --bg-main: #171d24;
    --bg-card: rgba(34, 41, 51, 0.88);
    --bg-card-border: rgba(255, 255, 255, 0.09);
    --bg-input: #242c36;
    --primary: #ff8701;
    --primary-hover: #e07600;
    --primary-glow: rgba(255, 135, 1, 0.28);
    --secondary: #3566bb;
    --success: #61a229;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-main: #f4f6f8;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-border: rgba(226, 232, 240, 0.9);
    --bg-input: #ffffff;
    --text-main: #363f48;
    --text-muted: #64748b;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 135, 1, 0.4);
    border-radius: 10px;
}

/* Glass Card Acamon */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.35);
    padding: 1.75rem;
    transition: var(--transition);
}

.glass-card:hover {
    border-color: rgba(255, 135, 1, 0.25);
    box-shadow: 0 15px 35px -10px rgba(255, 135, 1, 0.15);
}

/* Layout */
.app-container {
    display: flex;
    width: 100vw;
    min-height: 100vh;
}

/* Sidebar Acamon Style */
.sidebar {
    width: var(--sidebar-width);
    background: #11161d;
    border-right: 1px solid var(--bg-card-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--bg-card-border);
}

.sidebar-logo {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), #e07600);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.sidebar-brand {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.sidebar-brand span {
    color: var(--primary);
}

.sidebar-menu {
    list-style: none;
    padding: 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.92rem;
    transition: var(--transition);
}

.menu-item a:hover, .menu-item.active a {
    background: linear-gradient(90deg, var(--primary-glow), transparent);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

.menu-item i {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
}

/* Sidebar Mobile Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 999;
}
.sidebar-overlay.active {
    display: block;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100vw - var(--sidebar-width));
}

.topbar {
    height: var(--header-height);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--bg-card-border);
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title {
    font-size: 1.35rem;
    font-weight: 700;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-input);
    padding: 0.4rem 0.85rem;
    border-radius: 30px;
    border: 1px solid var(--bg-card-border);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    object-fit: cover;
}

.content-wrapper {
    padding: 2rem;
    flex: 1;
}

/* Buttons Touch Optimized */
.btn {
    padding: 0.75rem 1.35rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    min-height: 44px;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--primary-glow);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--bg-card-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

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

.btn-danger:hover {
    opacity: 0.9;
}

/* Form Controls Touch Friendly */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    min-height: 44px;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 1rem; /* Minimum 16px to prevent iOS auto-zoom */
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ff8701' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.1em;
}

/* Grid & Dashboard Stats */
.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    background: var(--primary-glow);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
}

.stat-title {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Data Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    text-align: left;
    min-width: 600px;
}

.custom-table th {
    padding: 0.85rem 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--bg-card-border);
}

.custom-table td {
    padding: 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--bg-card-border);
}

.custom-table tbody tr:hover {
    background: rgba(255, 135, 1, 0.05);
}

/* Badges Acamon Style */
.badge {
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    display: inline-block;
}

.badge-success {
    background: rgba(97, 162, 41, 0.18);
    color: #4ade80;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
}

.badge-info {
    background: rgba(53, 102, 187, 0.22);
    color: #60a5fa;
}

/* Wizard Grid Layout */
.wizard-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.form-grid-cep {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr;
    gap: 1rem;
}

.form-grid-cep-obra {
    display: grid;
    grid-template-columns: 1fr 3fr;
    gap: 1rem;
}

/* Live Calc Widget Acamon */
.live-preview-box {
    background: linear-gradient(135deg, rgba(255, 135, 1, 0.12), rgba(53, 102, 187, 0.08));
    border: 1px solid rgba(255, 135, 1, 0.35);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    position: sticky;
    top: 90px;
}

/* Toasts Responsive */
.toast-container {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 999999 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--bg-card-border);
    color: var(--text-main);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    animation: slideIn 0.3s ease;
}

.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-error { border-left: 4px solid var(--danger); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* =================================================================
 * OTIMIZAÇÃO COMPLETA E RESPONSIVA PARA CELULARES
 * ================================================================= */

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 5px 0 25px rgba(0,0,0,0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100vw;
    }

    #mobile-sidebar-toggle {
        display: inline-flex !important;
    }

    .topbar {
        padding: 0 1rem;
    }

    .content-wrapper {
        padding: 1.25rem 1rem;
    }

    .wizard-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 2.2rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    h3 {
        font-size: 1.2rem !important;
    }

    /* Converter todas as sub-grids de formulário para 1 coluna no celular */
    .form-grid-2,
    .form-grid-3,
    .form-grid-cep,
    .form-grid-cep-obra {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* Otimização dos Passos do Wizard no Celular */
    .wizard-steps {
        gap: 0.5rem;
    }

    .step-text-title {
        display: none !important;
    }

    .step-text-sub {
        font-size: 0.7rem !important;
    }

    .step-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 0.95rem !important;
    }

    .live-preview-box {
        position: relative;
        top: 0;
        margin-top: 1.5rem;
    }

    .glass-card {
        padding: 1.25rem;
        border-radius: var(--radius-md);
    }

    .auth-card {
        padding: 1.5rem;
        max-width: 92vw;
    }

    /* Modal Responsive */
    [id*="modal"] > div {
        max-width: 95vw !important;
        padding: 1.25rem !important;
    }

    /* Botões empilhados no mobile quando necessário */
    .wizard-nav-buttons {
        flex-direction: column-reverse;
        gap: 0.85rem;
        width: 100%;
    }

    .wizard-nav-buttons button,
    .wizard-nav-buttons .btn,
    .wizard-nav-buttons a {
        width: 100% !important;
        font-size: 0.95rem !important;
        padding: 0.85rem 1rem !important;
        justify-content: center;
        text-align: center;
        box-sizing: border-box;
        white-space: normal;
    }

    /* Toast Notification no Rodapé no Mobile */
    .toast-container {
        left: 15px;
        right: 15px;
        bottom: 15px;
    }

    .toast {
        min-width: auto;
        width: 100%;
    }
}

/* Modals Overlay Global */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.78) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    z-index: 99999 !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1rem !important;
    box-sizing: border-box !important;
}

.modal-card {
    position: relative !important;
    z-index: 100000 !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6) !important;
}

/* Select & Option Dark Theme Fix */
select option {
    background-color: #1e293b !important;
    color: #f8fafc !important;
    padding: 0.5rem !important;
}

select option:hover,
select option:focus,
select option:checked {
    background-color: #ff8701 !important;
    color: #ffffff !important;
}
