/* =========================================================
   KFOODY - SISTEMA GLOBAL
   ========================================================= */


/* =========================================================
   1. VARIÁVEIS
   ========================================================= */

:root {

    /* CORES */

    --primary: #FF7A00;
    --primary-light: #FFF1E6;
    --primary-hover: #E96D00;

    --dark: #1F2937;

    --background: #F8FAFC;
    --white: #FFFFFF;

    --text: #111827;
    --text-secondary: #64748B;

    --border: #E5E7EB;
    --border-light: #EEF0F3;

    --success: #16A34A;
    --success-light: #DCFCE7;

    --warning: #D97706;
    --warning-light: #FEF3C7;

    --danger: #DC2626;
    --danger-light: #FEF2F2;

    --neutral: #64748B;
    --neutral-light: #F1F5F9;


    /* TIPOGRAFIA */

    --font-family: Arial, Helvetica, sans-serif;

    --font-xs: 11px;
    --font-sm: 12px;
    --font-md: 14px;
    --font-lg: 16px;
    --font-xl: 18px;
    --font-2xl: 22px;
    --font-3xl: 28px;


    /* ESPAÇAMENTOS */

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 28px;
    --space-8: 32px;


    /* BORDAS */

    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 14px;
    --radius-full: 999px;


    /* SOMBRAS */

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.03);

    --shadow: 0 2px 8px rgba(15, 23, 42, 0.06);

    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);


    /* FORMULÁRIOS */

    --input-height: 42px;

    --input-border: #D9DEE7;

    --input-border-hover: #BFC6D1;

    --input-focus-shadow:
        0 0 0 3px rgba(255, 121, 0, 0.12);


    /* GRID */

    --grid-gap: 20px;

}


/* =========================================================
   2. RESET
   ========================================================= */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


html {
    width: 100%;
    min-height: 100%;
}


body {
    width: 100%;
    min-height: 100vh;

    font-family: var(--font-family);

    background: var(--background);

    color: var(--text);

    line-height: 1.4;

    -webkit-text-size-adjust: 100%;
}


/* =========================================================
   3. ELEMENTOS BÁSICOS
   ========================================================= */

button,
input,
select,
textarea {
    font-family: inherit;
}


/*
 * Mantemos 16px nos campos para evitar o zoom automático
 * do navegador em dispositivos móveis.
 */

input,
select,
textarea {
    font-size: 16px;
}


button {
    cursor: pointer;
}


a {
    color: inherit;
}


/* =========================================================
   4. LAYOUT
   ========================================================= */

.page {
    width: 100%;
    min-height: 100vh;

    background: var(--background);
}


.content {
    width: 100%;

    padding: var(--space-8);
}


/* =========================================================
   5. GRID
   ========================================================= */

.grid {
    width: 100%;

    display: flex;

    flex-wrap: wrap;

    gap: var(--grid-gap);

    align-items: flex-start;
}


/* =========================================================
   6. LARGURAS
   ========================================================= */

/*
 * As larguras funcionam diretamente dentro de .grid.
 *
 * Exemplo:
 *
 * <div class="grid">
 *     <div class="w25">...</div>
 *     <div class="w25">...</div>
 *     <div class="w50">...</div>
 * </div>
 *
 * Não é necessário criar um container dentro de outro.
 */

.w25 {
    flex: 0 0 calc(25% - 15px);
    max-width: calc(25% - 15px);
}


.w33 {
    flex: 0 0 calc(33.333333% - 13.333333px);
    max-width: calc(33.333333% - 13.333333px);
}


.w50 {
    flex: 0 0 calc(50% - 10px);
    max-width: calc(50% - 10px);
}


.w66 {
    flex: 0 0 calc(66.666667% - 6.666667px);
    max-width: calc(66.666667% - 6.666667px);
}


.w75 {
    flex: 0 0 calc(75% - 5px);
    max-width: calc(75% - 5px);
}


.w100 {
    flex: 0 0 100%;
    max-width: 100%;
}


/* =========================================================
   7. TIPOGRAFIA
   ========================================================= */

.title {
    color: var(--text);

    font-size: var(--font-3xl);

    font-weight: 700;

    line-height: 1.25;
}


.subtitle {
    color: var(--text);

    font-size: var(--font-lg);

    font-weight: 600;

    line-height: 1.3;
}


.text {
    color: var(--text);

    font-size: var(--font-md);

    line-height: 1.5;
}


.text-secondary {
    color: var(--text-secondary);

    font-size: var(--font-md);

    line-height: 1.5;
}


.text-small {
    color: var(--text-secondary);

    font-size: var(--font-sm);

    line-height: 1.4;
}


.text-xs {
    color: var(--text-secondary);

    font-size: var(--font-xs);

    line-height: 1.4;
}


/* =========================================================
   8. CABEÇALHO DE PÁGINA
   ========================================================= */

.page-header {
    width: 100%;

    margin-bottom: var(--space-6);
}


.page-header h1 {
    color: var(--text);

    font-size: var(--font-3xl);

    font-weight: 700;

    line-height: 1.25;

    margin-bottom: 5px;
}


.page-header p {
    color: var(--text-secondary);

    font-size: var(--font-md);
}


/* =========================================================
   9. CARDS
   ========================================================= */

.card {
    width: 100%;

    background: var(--white);

    border: 1px solid var(--border);

    border-radius: var(--radius-md);

    box-shadow: var(--shadow-sm);
}


.card-header {
    padding: var(--space-5) var(--space-6);

    border-bottom: 1px solid var(--border);
}


.card-body {
    padding: var(--space-6);
}


.card-footer {
    padding: var(--space-5) var(--space-6);

    border-top: 1px solid var(--border);
}


/* =========================================================
   10. CAMPOS
   ========================================================= */

.field {
    width: 100%;

    display: flex;

    flex-direction: column;

    gap: 7px;
}


.field-label {
    color: var(--text);

    font-size: 13px;

    font-weight: 600;
}


.input,
.select,
.textarea {
    width: 100%;

    border: 1px solid var(--input-border);

    border-radius: var(--radius);

    background: var(--white);

    color: var(--text);

    font-family: inherit;

    outline: none;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}


.input,
.select {
    height: var(--input-height);

    padding: 0 14px;
}


.textarea {
    min-height: 105px;

    padding: 12px 14px;

    resize: vertical;
}


.select {
    cursor: pointer;
}


.input::placeholder,
.textarea::placeholder {
    color: #9CA3AF;
}


.input:hover,
.select:hover,
.textarea:hover {
    border-color: var(--input-border-hover);
}


.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--primary);

    box-shadow: var(--input-focus-shadow);
}


/* =========================================================
   11. BOTÕES
   ========================================================= */

.btn {
    min-height: var(--input-height);

    display: inline-flex;

    align-items: center;

    justify-content: center;

    gap: var(--space-2);

    padding: 0 18px;

    border: 1px solid transparent;

    border-radius: var(--radius);

    font-family: inherit;

    font-size: var(--font-md);

    font-weight: 600;

    line-height: 1;

    text-decoration: none;

    white-space: nowrap;

    cursor: pointer;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.1s ease;
}


.btn:active {
    transform: translateY(1px);
}


/* Principal */

.btn-primary {
    background: var(--primary);

    border-color: var(--primary);

    color: var(--white);
}


.btn-primary:hover {
    background: var(--primary-hover);

    border-color: var(--primary-hover);
}


/* Secundário */

.btn-secondary {
    background: var(--white);

    border-color: #D1D5DB;

    color: #374151;
}


.btn-secondary:hover {
    background: #F9FAFB;

    border-color: #9CA3AF;
}


/* Perigo */

.btn-danger {
    background: var(--white);

    border-color: #FECACA;

    color: var(--danger);
}


.btn-danger:hover {
    background: var(--danger-light);

    border-color: #FCA5A5;
}


/* =========================================================
   12. TABELAS
   ========================================================= */

.table-container {
    width: 100%;

    overflow-x: auto;
}


.table {
    width: 100%;

    border-collapse: collapse;

    font-size: var(--font-md);
}


.table thead {
    background: var(--background);
}


.table th {
    padding: 14px 16px;

    text-align: left;

    color: var(--text-secondary);

    font-size: var(--font-xs);

    font-weight: 600;

    text-transform: uppercase;

    letter-spacing: 0.04em;

    border-bottom: 1px solid var(--border);
}


.table td {
    padding: 16px;

    color: var(--text);

    border-bottom: 1px solid var(--border-light);

    vertical-align: middle;
}


.table tbody tr {
    transition: background 0.15s ease;
}


.table tbody tr:hover {
    background: #FAFAFA;
}


/* =========================================================
   13. BADGES
   ========================================================= */

.badge {
    display: inline-flex;

    align-items: center;

    justify-content: center;

    min-height: 24px;

    padding: 4px 10px;

    border-radius: var(--radius-full);

    font-size: var(--font-sm);

    font-weight: 600;

    white-space: nowrap;
}


.badge-success {
    color: #15803D;

    background: var(--success-light);
}


.badge-warning {
    color: #B45309;

    background: var(--warning-light);
}


.badge-danger {
    color: #B91C1C;

    background: #FEE2E2;
}


.badge-neutral {
    color: var(--neutral);

    background: var(--neutral-light);
}


/* =========================================================
   14. ESTADO VAZIO
   ========================================================= */

.empty {
    width: 100%;

    text-align: center;

    padding: 60px 20px;
}


.empty-title {
    margin-bottom: 8px;

    color: var(--text);

    font-size: var(--font-lg);

    font-weight: 600;
}


.empty-text {
    color: var(--text-secondary);

    font-size: var(--font-md);
}


/* =========================================================
   15. AÇÕES
   ========================================================= */

.actions {
    display: flex;

    align-items: center;

    justify-content: flex-end;

    gap: var(--space-2);

    flex-wrap: wrap;
}


.actions-between {
    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: var(--space-4);

    flex-wrap: wrap;
}


/* =========================================================
   16. DIVISOR
   ========================================================= */

.divider {
    width: 100%;

    height: 1px;

    background: var(--border);
}


/* =========================================================
   17. RESPONSIVIDADE
   ========================================================= */

@media (max-width: 1000px) {

    .w25 {
        flex-basis: calc(50% - 10px);
        max-width: calc(50% - 10px);
    }

    .w33 {
        flex-basis: calc(50% - 10px);
        max-width: calc(50% - 10px);
    }

    .w66,
    .w75 {
        flex-basis: 100%;
        max-width: 100%;
    }

}


@media (max-width: 768px) {

    .content {
        padding: var(--space-5);
    }

    .grid {
        gap: 17px;
    }

    .w25,
    .w33,
    .w50,
    .w66,
    .w75,
    .w100 {
        flex-basis: 100%;
        max-width: 100%;
    }

    .title {
        font-size: 24px;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .card-body {
        padding: var(--space-5);
    }

    .card-header {
        padding: var(--space-4) var(--space-5);
    }

    .card-footer {
        padding: var(--space-4) var(--space-5);
    }

    .actions,
    .actions-between {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .actions .btn,
    .actions-between .btn {
        width: 100%;
    }


    /* =====================================================
       TABELAS NO MOBILE
       ===================================================== */

    .table-container {
        width: 100%;
        overflow: visible;
    }

    .table {
        display: block;
        width: 100%;
        min-width: 0;
        border: 0;
        border-collapse: separate;
        border-spacing: 0;
    }

    .table thead {
        display: none;
    }

    .table tbody {
        display: block;
        width: 100%;
    }

    .table tbody tr.sortable-item {
        display: grid;
        grid-template-columns: 45px minmax(0, 1fr);
        margin: 12px 8px;
        width: calc(100% - 16px);
        padding: 14px;
        box-sizing: border-box;

        background: var(--white);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);

        cursor: grab;
    }

    .table tbody tr.sortable-item.arrastando {
        opacity: 0.45;
        border-color: var(--primary);
    }

    .table tbody tr.sortable-item>td {
        display: flex;
        align-items: center;

        min-width: 0;
        width: auto;
        padding: 7px 0;

        border: 0;
        background: transparent;
    }

    /* Alça de arrastar */
    .table tbody tr.sortable-item>td:first-child {
        grid-column: 1;
        grid-row: 1 / span 6;

        align-items: center;
        justify-content: center;

        padding-right: 10px;
    }

    /* Foto */
    .table tbody tr.sortable-item>td:nth-child(2) {
        grid-column: 2;
        padding-bottom: 10px;
    }

    /* Demais campos */
    .table tbody tr.sortable-item>td[data-label] {
        grid-column: 2;

        display: flex;
        align-items: center;
        gap: 8px;
    }

    .table tbody tr.sortable-item>td[data-label]::before {
        content: attr(data-label);

        flex-shrink: 0;
        min-width: 78px;

        color: var(--text-secondary);
        font-size: var(--font-xs);
        font-weight: 600;

        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    /* Nome */
    .table tbody tr.sortable-item>td[data-label="Nome"] {
        font-size: 15px;
        font-weight: 600;
    }

    /* Descrição */
    .table tbody tr.sortable-item>td[data-label="Descrição"] {
        color: var(--text-secondary);
        font-size: 13px;
    }

    /* Status */
    .table tbody tr.sortable-item>td[data-label="Status"] {
        padding-top: 8px;
        padding-bottom: 8px;
    }

    /* Ações */
    .table tbody tr.sortable-item>td[data-label="Ações"] {
        padding-top: 8px;
    }

    .table tbody tr.sortable-item>td[data-label="Ações"] .btn {
        width: 100%;
    }

    /* Alça */
    .sortable-handle {
        width: 38px;
        height: 45px;

        display: flex;
        align-items: center;
        justify-content: center;

        font-size: 24px;

        user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
        touch-action: none;
    }

    /* Botões dos formulários */
    .form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .form-actions>div {
        width: 100%;
    }

    .form-actions .actions {
        width: 100%;
    }
}

/* =========================================================
   18. CABEÇALHO / VOLTAR
   ========================================================= */

.btn-back {
    display: inline-flex;

    align-items: center;

    gap: var(--space-2);

    color: var(--text-secondary);

    font-size: var(--font-md);

    font-weight: 600;

    text-decoration: none;

    transition: color 0.2s ease;
}

.btn-back:hover {
    color: var(--primary);
}


/* =========================================================
   19. SEÇÕES DE FORMULÁRIO
   ========================================================= */

.form-section {
    width: 100%;

    margin-top: var(--space-8);

    padding-top: var(--space-6);

    border-top: 1px solid var(--border);
}


.form-section-title {
    margin-bottom: var(--space-5);
}


.form-section-title .subtitle {
    margin-bottom: var(--space-1);
}


/* =========================================================
   20. IMAGEM
   ========================================================= */

.list-image {
    width: 52px;
    height: 52px;

    border-radius: 8px;

    overflow: hidden;

    background: var(--neutral-light);

    border: 1px solid var(--border);

    display: flex;

    align-items: center;

    justify-content: center;
}


.list-image img {
    width: 100%;
    height: 100%;

    object-fit: cover;

    display: block;
}


.list-image-placeholder {
    width: 100%;
    height: 100%;

    display: flex;

    align-items: center;
    justify-content: center;

    color: var(--text-secondary);

    font-size: 20px;
}


@media (max-width: 768px) {

    .list-image {
        width: 45px;
        height: 45px;
    }

}


.image-preview {
    position: relative;

    display: flex;

    align-items: center;

    justify-content: center;

    width: 100%;

    aspect-ratio: 1 / 1;

    overflow: hidden;

    border: 2px dashed var(--border);

    border-radius: var(--radius-lg);

    background: var(--neutral-light);

    cursor: pointer;

    transition:
        border-color 0.2s ease,
        background 0.2s ease;
}


.image-preview:hover {
    border-color: var(--primary);

    background: var(--primary-light);
}


.image-preview img {
    display: block;

    width: 100%;

    height: 100%;

    object-fit: cover;
}


.image-placeholder {
    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    width: 100%;

    height: 100%;

    padding: var(--space-4);

    text-align: center;
}


.image-placeholder span {
    display: block;

    margin-bottom: var(--space-3);

    font-size: 32px;
}


.image-placeholder strong {
    display: block;

    margin-bottom: var(--space-1);

    color: var(--text);

    font-size: var(--font-md);

    font-weight: 600;
}


.image-placeholder small {
    display: block;

    max-width: 180px;

    color: var(--text-secondary);

    font-size: var(--font-sm);

    line-height: 1.4;
}

/* =========================================================
   21. CHECKBOX
   ========================================================= */

.list-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    width: 100%;
}

.check-option {
    position: relative;

    display: flex;

    align-items: center;

    gap: var(--space-3);

    width: 100%;

    min-height: 72px;

    padding: var(--space-4);

    border: 1px solid var(--border);

    border-radius: var(--radius);

    background: var(--white);

    cursor: pointer;

    transition:
        border-color 0.2s ease,
        background 0.2s ease;
}


/* Esconde o checkbox original */

.check-option input[type="checkbox"] {
    position: absolute;

    opacity: 0;

    pointer-events: none;
}


/* Caixa visual */

.check-box {
    position: relative;

    width: 20px;
    height: 20px;

    flex-shrink: 0;

    border: 2px solid #CBD5E1;

    border-radius: 5px;

    background: var(--white);

    transition:
        background 0.2s ease,
        border-color 0.2s ease;
}


/* Checkbox marcado */

.check-option input[type="checkbox"]:checked~.check-box {
    border-color: var(--primary);

    background: var(--primary);

    box-shadow:
        inset 0 0 0 1px var(--primary);
}


/* Marca */

.check-option input[type="checkbox"]:checked~.check-box::after {
    content: "✓";

    display: flex;

    align-items: center;

    justify-content: center;

    width: 100%;
    height: 100%;

    color: var(--white);

    font-size: 13px;

    font-weight: 700;

    line-height: 1;
}


/* Hover */

.check-option:hover {
    border-color: #CBD5E1;

    background: #FAFAFA;
}


/* Conteúdo */

.check-content {
    display: flex;

    flex-direction: column;

    gap: var(--space-1);
}


.check-content strong {
    color: var(--text);

    font-size: var(--font-md);

    font-weight: 600;
}


.check-content small {
    color: var(--text-secondary);

    font-size: var(--font-sm);

    line-height: 1.4;
}

/* =========================================================
   22. AÇÕES DO FORMULÁRIO
   ========================================================= */

.form-actions {
    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: var(--space-4);

    width: 100%;

    margin-top: var(--space-8);

    padding-top: var(--space-5);

    border-top: 1px solid var(--border);
}


.form-actions>div {
    display: flex;

    align-items: center;

    gap: var(--space-3);
}


@media (max-width: 768px) {

    .form-actions {
        flex-direction: column-reverse;

        align-items: stretch;
    }


    .form-actions>div {
        width: 100%;
    }


    .form-actions .actions {
        width: 100%;
    }

}

/* =========================================================
   23. STATUS DA EMPRESA
   ========================================================= */

.empresa-status-form {
    display: flex;

    align-items: center;

    margin-left: var(--space-4);
}


.empresa-status-button {
    display: inline-flex;

    align-items: center;

    gap: var(--space-2);

    min-height: 36px;

    padding: 0 14px;

    border: 1px solid transparent;

    border-radius: var(--radius-full);

    background: var(--white);

    font-family: inherit;

    font-size: var(--font-sm);

    font-weight: 600;

    line-height: 1;

    cursor: pointer;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease;
}


/* Empresa recebendo pedidos */

.empresa-status-button.status-aberto {
    color: #15803D;

    background: var(--success-light);

    border-color: #BBF7D0;
}


.empresa-status-button.status-aberto:hover {
    background: #BBF7D0;

    border-color: #86EFAC;
}


/* Empresa com pedidos pausados */

.empresa-status-button.status-fechado {
    color: #B91C1C;

    background: var(--danger-light);

    border-color: #FECACA;
}


.empresa-status-button.status-fechado:hover {
    background: #FEE2E2;

    border-color: #FCA5A5;
}


/* Indicador */

.empresa-status-indicador {
    font-size: 9px;

    line-height: 1;
}


.empresa-status-button.status-aberto .empresa-status-indicador {
    color: var(--success);
}


.empresa-status-button.status-fechado .empresa-status-indicador {
    color: var(--danger);
}


/* =========================================================
   STATUS DA EMPRESA - MOBILE
   ========================================================= */

@media (max-width: 768px) {

    .empresa-status-form {
        margin-left: var(--space-3);
    }

    .empresa-status-button {
        min-height: 34px;

        padding: 0 11px;

        font-size: var(--font-xs);
    }

}
