/* ===================================
   CLABAG - SISTEMA DE PEDIDOS
   Design inspirado em Cladora Concept
   =================================== */

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

:root {
    --primary-gold: #C4A747;
    --dark-gold: #B39636;
    --cream: #FFFBF5;
    --dark-text: #5A5A5A;
    --light-text: #8B8B8B;
    --bg-light: #FFFFFF;
    --success-color: #4CAF50;
    --error-color: #F44336;
    --warning-color: #FF9800;
    --info-color: #2196F3;
}

html {
    scroll-behavior: smooth;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--primary-gold);
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    letter-spacing: 0.5px;
}

h1 {
    font-size: 32px;
}

h2 {
    font-size: 28px;
}

h3 {
    font-size: 20px;
}

h4 {
    font-size: 18px;
}

h5 {
    font-size: 16px;
}

h6 {
    font-size: 14px;
}

body {
    font-family: 'Montserrat', sans-serif;
    background: #FFFFFF;
    color: var(--primary-gold);
    min-height: 100vh;
}

/* ===== HEADER ===== */
.header {
    background: white;
    padding: 20px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-section img {
    height: 50px;
    width: auto;
}

.header-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-gold);
    letter-spacing: 1px;
}

.header-subtitle {
    font-size: 12px;
    color: var(--light-text);
    font-weight: 300;
}

/* ===== CONTAINER ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.container-small {
    max-width: 700px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Painel admin: usa toda a largura razoável da tela (escala em monitores grandes) */
.container-admin {
    max-width: 1600px;
    margin: 0 auto;
    padding: 30px 28px;
}
@media (min-width: 1700px) {
    .container-admin { max-width: 1800px; }
}
@media (min-width: 2000px) {
    .container-admin { max-width: 1920px; }
}
@media (max-width: 720px) {
    .container-admin { padding: 20px 14px; }
}

/* ===== CARD ===== */
.card {
    background: #FFFFFF;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 40px;
    animation: slideIn 0.5s ease-out;
}

.card-header {
    margin-bottom: 30px;
    text-align: center;
}

.card-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-gold);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.card-subtitle {
    font-size: 14px;
    color: var(--primary-gold);
    font-weight: 400;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== FORM ===== */
.form-group {
    margin-bottom: 25px;
}

.form-group.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

label {
    display: block;
    font-family: 'Cormorant Garamond', serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--primary-gold);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.label-required::after {
    content: " *";
    color: var(--error-color);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #E8E8E8;
    border-radius: 6px;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    color: var(--primary-gold);
    transition: all 0.3s ease;
    background: #FFFFFF;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-gold);
    background: white;
    box-shadow: 0 0 0 3px rgba(212, 184, 150, 0.2);
}

textarea {
    resize: vertical;
    min-height: 100px;
    font-family: 'Montserrat', sans-serif;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23C4A747' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
}

/* ===== FILE UPLOAD ===== */
.file-upload-group {
    margin-bottom: 25px;
}

.file-upload-label {
    display: block;
    padding: 30px;
    border: 2px dashed #D4B896;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(212, 184, 150, 0.03);
}

.file-upload-label:hover {
    border-color: var(--dark-gold);
    background: rgba(212, 184, 150, 0.06);
}

.file-upload-label.dragover {
    border-color: var(--dark-gold);
    background: rgba(212, 184, 150, 0.1);
}

.file-upload-icon {
    font-size: 32px;
    margin-bottom: 10px;
}

.file-upload-text {
    font-size: 14px;
    color: var(--light-text);
    margin-bottom: 5px;
}

.file-upload-subtext {
    font-size: 12px;
    color: var(--light-text);
}

input[type="file"] {
    display: none;
}

.file-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.file-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.file-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

.file-item-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.file-item-remove:hover {
    background: #d32f2f;
    transform: scale(1.1);
}

/* ===== CHECKBOX & RADIO ===== */
.checkbox-group,
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkbox-item,
.radio-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-gold);
}

.checkbox-label,
.radio-label {
    font-size: 14px;
    color: var(--primary-gold);
    cursor: pointer;
    margin: 0;
    font-weight: 400;
}

/* ===== BUTTONS ===== */
.button-group {
    display: flex;
    gap: 12px;
    margin-top: 35px;
}

button,
.btn {
    padding: 14px 24px;
    border: none;
    border-radius: 6px;
    font-family: 'Montserrat', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.5px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: var(--primary-gold);
    color: white;
    box-shadow: 0 4px 15px rgba(212, 184, 150, 0.4);
    flex: 1;
    font-weight: 700;
}

.btn-primary:hover {
    background: var(--dark-gold);
    box-shadow: 0 6px 20px rgba(196, 168, 118, 0.5);
    transform: translateY(-2px);
}

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

.btn-secondary {
    background: transparent;
    color: var(--primary-gold);
    flex: 1;
    border: 2px solid var(--primary-gold);
    font-weight: 700;
}

.btn-secondary:hover {
    background: rgba(212, 184, 150, 0.1);
}

.btn-small {
    padding: 10px 16px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
    display: block;
}

/* ===== MESSAGES ===== */
.message {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: none;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.message.success {
    background: #E8F5E9;
    color: #2E7D32;
    border-left: 4px solid var(--success-color);
    display: block;
}

.message.error {
    background: #FFEBEE;
    color: #C62828;
    border-left: 4px solid var(--error-color);
    display: block;
}

.message.warning {
    background: #FFF3E0;
    color: #E65100;
    border-left: 4px solid var(--warning-color);
    display: block;
}

.message.info {
    background: #E3F2FD;
    color: #1565C0;
    border-left: 4px solid var(--info-color);
    display: block;
}

/* ===== LOADING ===== */
.loading {
    display: none;
    text-align: center;
    color: var(--primary-gold);
    font-weight: 600;
}

.loading.show {
    display: block;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #F0EAE0;
    border-top-color: var(--primary-gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== STEPS ===== */
.steps-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
    position: relative;
}

.steps-container::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 2px;
    background: #F0EAE0;
    z-index: 0;
}

.step {
    flex: 1;
    text-align: center;
    position: relative;
    z-index: 1;
}

.step-number {
    width: 40px;
    height: 40px;
    background: #F0EAE0;
    color: var(--light-text);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.step.active .step-number {
    background: var(--primary-gold);
    color: white;
    box-shadow: 0 4px 12px rgba(196, 167, 71, 0.3);
}

.step.completed .step-number {
    background: var(--success-color);
    color: white;
}

.step-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--light-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.step.active .step-title {
    color: var(--primary-gold);
}

/* ===== ADMIN PANEL ===== */
.admin-header {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-header h1 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 28px;
    color: var(--primary-gold);
    letter-spacing: 1px;
}

.admin-info {
    text-align: right;
    font-size: 13px;
    color: var(--light-text);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    border-left: 4px solid var(--primary-gold);
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--light-text);
    letter-spacing: 1px;
    margin-bottom: 8px;
    font-weight: 600;
}

.stat-value {
    font-family: 'Cormorant Garamond', serif;
    font-size: 32px;
    font-weight: 600;
    color: var(--primary-gold);
}

.stat-subtext {
    font-size: 12px;
    color: var(--light-text);
    margin-top: 8px;
}

/* ===== TABLE ===== */
.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.table-header {
    background: var(--bg-light);
    padding: 20px 25px;
    border-bottom: 1px solid #F0EAE0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-gold);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: var(--bg-light);
    padding: 15px 20px;
    text-align: left;
    font-weight: 700;
    color: var(--primary-gold);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #F0EAE0;
}

td {
    padding: 15px 20px;
    border-bottom: 1px solid #F0EAE0;
    font-size: 14px;
}

tr:hover {
    background: var(--bg-light);
}

/* ===== BADGE ===== */
.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: #E8F5E9;
    color: #2E7D32;
}

.badge-error {
    background: #FFEBEE;
    color: #C62828;
}

.badge-warning {
    background: #FFF3E0;
    color: #E65100;
}

.badge-info {
    background: #E3F2FD;
    color: #1565C0;
}

.badge-pending {
    background: #F3E5F5;
    color: #6A1B9A;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .card {
        padding: 25px;
    }

    .card-title {
        font-size: 24px;
    }

    .form-group.form-row,
    .form-group.form-row-3 {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    .admin-header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

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

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

    .steps-container {
        flex-wrap: wrap;
    }

    .step {
        flex: 0 0 25%;
    }

    table {
        font-size: 12px;
    }

    td, th {
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    .container,
    .container-small {
        padding: 20px 15px;
    }

    .card {
        padding: 20px;
    }

    .card-title {
        font-size: 20px;
    }

    label {
        font-size: 16px;
    }

    .header-title {
        font-size: 18px;
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-gold);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--dark-gold);
}

/* ===== EXTRAS VERSÃO 2.0 ===== */

/* Btn-small sem flex:1 para uso fora de button-group */
a.btn-small, button.btn-small {
    flex: none;
}

/* Grid de detalhes admin */
@media (max-width: 900px) {
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* Imagens de referência */
.refs-grid img {
    display: block;
    width: 100%;
    height: 110px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #F0EAE0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.refs-grid img:hover {
    box-shadow: 0 4px 12px rgba(212, 184, 150, 0.3);
    transform: scale(1.04);
}

/* Upload drag-over */
.file-upload-label.dragover {
    border-color: var(--primary-gold);
    background: rgba(212, 184, 150, 0.08);
    transform: scale(1.01);
}

/* Área do cliente - responsivo */
@media (max-width: 480px) {
    .limite-cards {
        grid-template-columns: 1fr 1fr !important;
    }
    .data-table th:nth-child(3),
    .data-table td:nth-child(3) {
        display: none;
    }
}

/* Animação suave para cards */
.section-card, .detail-section, .resumo-box, .pagamento-box {
    animation: slideIn 0.4s ease-out;
}

/* Botão de logout no header */
.header .btn-secondary {
    flex: none;
    padding: 8px 16px;
    font-size: 12px;
}


/* ============================================================================
   PWA — SAFE AREA (iPhone notch / barra de status / Dynamic Island)
   ============================================================================
   Regra de ouro: NÃO aplicar padding-top no body. O header fica sticky/fixo
   no topo e ELE absorve a safe-area-inset-top via padding interno.
   Isso evita o "conteúdo colando na barra de status" do iPhone.
   ============================================================================ */

/* No browser comum (não-PWA), só compensa o left/right do notch quando em landscape */
@supports (padding: max(0px)) {
    body {
        padding-left:  env(safe-area-inset-left, 0);
        padding-right: env(safe-area-inset-right, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* HEADER absorve a safe-area-inset-top sempre que existe (iPhone com notch).
   Funciona tanto no Safari normal quanto no PWA standalone. */
.header {
    padding-top: max(20px, env(safe-area-inset-top, 20px)) !important;
    padding-left:  env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

/* ===== MODO STANDALONE (PWA instalado) =====
   Quando o app é aberto da tela inicial (sem barra de endereço do navegador),
   o header fica fixo no topo, e o conteúdo do container precisa de margem
   superior compatível com a altura do header + safe-area. */
@media (display-mode: standalone) {

    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        /* Já tem padding-top com safe-area da regra acima */
    }

    /* Container deve começar abaixo do header (altura aproximada: 60px header
       + safe-area no topo). Usamos calc para somar tudo. */
    .container,
    .container-small {
        margin-top: calc(70px + env(safe-area-inset-top, 0));
    }

    /* Modais em fullscreen não precisam de margem extra — eles cobrem tudo */
    .modal-overlay {
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    /* Banner de instalação não aparece quando já está standalone, mas se
       aparecer (browser bug), respeita a safe area inferior */
    .install-banner {
        bottom: max(16px, env(safe-area-inset-bottom, 16px)) !important;
    }
}

/* iOS Safari mostra a barra do navegador no fim — quando rolada,
   o conteúdo precisa terminar acima dela */
.container,
.container-small {
    padding-bottom: max(40px, env(safe-area-inset-bottom, 40px));
}

/* Melhorias para tela pequena */
@media (max-width: 480px) {
    .header-content {
        padding: 0 12px;
    }
    
    .logo-section img {
        height: 40px;
    }
    
    .header-title {
        font-size: 18px;
    }
    
    .container, .container-small {
        padding: 20px 12px;
    }
    
    .card {
        padding: 16px;
        border-radius: 8px;
    }
    
    .file-preview {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .file-item {
        aspect-ratio: 1;
    }
}

/* Melhorias para tablet */
@media (min-width: 481px) and (max-width: 768px) {
    .container, .container-small {
        padding: 30px 20px;
    }
    
    .file-preview {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Melhorias para desktop */
@media (min-width: 769px) {
    .file-preview {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Animação de instalação PWA */
.install-prompt {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 20px;
    max-width: 350px;
    z-index: 999;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.install-prompt-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-gold);
    margin-bottom: 8px;
}

.install-prompt-text {
    font-size: 13px;
    color: var(--light-text);
    margin-bottom: 15px;
}

.install-prompt-buttons {
    display: flex;
    gap: 10px;
}

.install-prompt-buttons button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.install-prompt-buttons .btn-primary {
    background: var(--primary-gold);
    color: white;
}

.install-prompt-buttons .btn-primary:hover {
    background: var(--dark-gold);
}

.install-prompt-buttons .btn-secondary {
    background: #E8E0D0;
    color: var(--dark-text);
}

.install-prompt-buttons .btn-secondary:hover {
    background: #D8D0C0;
}

/* Modo claro apenas - sem dark mode */

/* Suporte para orientação landscape */
@media (max-height: 500px) {
    .container, .container-small {
        padding: 20px;
    }
    
    .card {
        padding: 20px;
    }
}

/* Otimização para impressão */
@media print {
    .header, .button-group, .modal-overlay, .install-prompt {
        display: none;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
