/* ============================================
   Agendamento Modal - Estilo Padrao do Sistema
   Segue o mesmo padrao visual do venda-modal
   ============================================ */

/* Header */
.agendamento-modal-header {
    background: linear-gradient(135deg, #43b581 0%, #2d8f63 100%);
    color: #fff;
    border-bottom: none;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.agendamento-modal-header .modal-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.agendamento-modal-header .close {
    color: #fff;
    opacity: 0.8;
    font-size: 1.4rem;
    font-weight: 300;
    text-shadow: none;
    margin: 0;
    padding: 0 4px;
}

.agendamento-modal-header .close:hover {
    opacity: 1;
}

/* Body */
.agendamento-modal-body {
    padding: 16px 20px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    background: #f8f9fa;
}

/* Secoes com label */
.agd-section {
    background: #fff;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 12px;
    border: 1px solid #e8e9ed;
}

.agd-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7f8c8d;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Alerta GCal compacto */
.agd-alert-gcal {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 6px 12px;
    margin-bottom: 12px;
    font-size: 11px;
    color: #856404;
    display: flex;
    align-items: center;
    gap: 6px;
}

.agd-alert-gcal i {
    color: #e0a800;
    font-size: 13px;
    flex-shrink: 0;
}

/* Campos inline */
.agd-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.agd-row:last-child {
    margin-bottom: 0;
}

.agd-field {
    flex: 1;
    min-width: 0;
}

.agd-field.agd-sm {
    flex: 0 0 130px;
}

.agd-field.agd-md {
    flex: 0 0 180px;
}

.agd-label {
    font-size: 11px;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.agd-field select,
.agd-field input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #dcdfe3;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    color: #2c3e50;
    transition: border-color 0.2s;
}

.agd-field select:focus,
.agd-field input:focus {
    border-color: #43b581;
    outline: none;
    box-shadow: 0 0 0 2px rgba(67, 181, 129, 0.15);
}

.agd-field .agd-readonly {
    background: #f1f3f5;
    font-weight: 600;
    text-align: center;
    cursor: default;
}

/* Tabela de servicos */
.agd-servicos-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.agd-servicos-table th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #7f8c8d;
    padding: 6px 8px;
    border-bottom: 2px solid #e8e9ed;
    text-align: left;
}

.agd-servicos-table td {
    padding: 8px;
    border-bottom: 1px solid #f1f3f5;
    vertical-align: middle;
}

.agd-servicos-table tr:last-child td {
    border-bottom: none;
}

.agd-servicos-table .agd-col-tempo,
.agd-servicos-table .agd-col-valor {
    text-align: right;
    white-space: nowrap;
}

.agd-servicos-table .agd-col-acao {
    width: 30px;
    text-align: center;
}

.agd-servicos-total {
    display: flex;
    justify-content: flex-end;
    gap: 20px;
    padding: 8px 8px 0;
    margin-top: 6px;
    border-top: 2px solid #e8e9ed;
    font-weight: 600;
    font-size: 13px;
    color: #2c3e50;
}

.agd-btn-remover {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: #fee;
    color: #e74c3c;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.15s;
    padding: 0;
}

.agd-btn-remover:hover {
    background: #e74c3c;
    color: #fff;
}

.agd-btn-add-servico {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px dashed #43b581;
    border-radius: 6px;
    background: transparent;
    color: #43b581;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.agd-btn-add-servico:hover {
    background: #e8f8f0;
    border-style: solid;
}

.agd-empty {
    text-align: center;
    padding: 12px;
    color: #adb5bd;
    font-size: 12px;
    font-style: italic;
}

/* Override do componente produto-venda dentro do modal de agendamento */
.agd-section .produto-info {
    background: linear-gradient(135deg, #e8f8f0 0%, #f0faf5 100%);
    border-color: #43b581;
    box-shadow: 0 1px 4px rgba(67, 181, 129, 0.12);
    padding: 10px 12px;
    border-radius: 8px;
    border-width: 1px;
}

.agd-section .produto-selecionado {
    margin-bottom: 10px;
}

.agd-section .btn-fechar-produto {
    border-color: #adb5bd;
    color: #6c757d;
    box-shadow: none;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    border-radius: 6px;
    border-width: 1px;
}

.agd-section .btn-fechar-produto:hover {
    background: #e74c3c;
    border-color: #e74c3c;
    color: #fff;
}

.agd-section .produto-nome {
    font-size: 0.8125rem;
}

.agd-section .produto-preco {
    color: #43b581;
    font-size: 0.875rem;
}

.agd-section .badge-primary {
    background: #43b581;
    font-size: 0.7rem;
    padding: 2px 6px;
}

.agd-section .busca-tabs {
    margin-bottom: 10px;
    border-radius: 8px;
    padding: 3px;
}

.agd-section .tab-btn {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8125rem;
}

.agd-section .tab-btn.active {
    color: #43b581;
}

.agd-section .input-group-sm {
    border-radius: 8px;
    border-width: 1px;
}

.agd-section .input-group-sm:focus-within {
    border-color: #43b581;
    box-shadow: 0 0 0 2px rgba(67, 181, 129, 0.12);
}

.agd-section .input-group-sm .btn-primary {
    color: #43b581;
}

.agd-section .input-group-sm .btn-primary:hover {
    background: rgba(67, 181, 129, 0.1);
}

.agd-section .form-text {
    font-size: 0.6875rem;
    margin-top: 4px;
}

/* Footer */
.agendamento-modal-footer {
    background: #fff;
    border-top: 1px solid #e8e9ed;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.agendamento-modal-footer .agd-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.agd-btn-salvar {
    background: #43b581;
    color: #fff;
}

.agd-btn-salvar:hover:not(:disabled) {
    background: #3aa374;
    box-shadow: 0 2px 8px rgba(67, 181, 129, 0.3);
}

.agd-btn-salvar:disabled {
    background: #b5d5c5;
    cursor: not-allowed;
}

.agd-btn-fechar {
    background: #e9ecef;
    color: #495057;
}

.agd-btn-fechar:hover {
    background: #dee2e6;
}

.agd-btn-excluir {
    background: transparent;
    color: #e74c3c;
    border: 1px solid #e74c3c;
}

.agd-btn-excluir:hover {
    background: #e74c3c;
    color: #fff;
}

/* Servico modal (selecao) */
.agd-servico-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom: none;
    padding: 12px 18px;
}

.agd-servico-modal-header .modal-title {
    font-size: 1rem;
    font-weight: 600;
}

.agd-servico-modal-header .close {
    color: #fff;
    opacity: 0.8;
    text-shadow: none;
}

.agd-servico-busca {
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #e8e9ed;
    position: sticky;
    top: 0;
    z-index: 5;
}

.agd-servico-busca input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid #dcdfe3;
    border-radius: 8px;
    font-size: 13px;
    background: #f8f9fa;
    transition: all 0.2s;
}

.agd-servico-busca input:focus {
    background: #fff;
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.agd-servico-busca .search-icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
    font-size: 13px;
    pointer-events: none;
}

.agd-servico-lista {
    max-height: 400px;
    overflow-y: auto;
    padding: 6px 0;
}

.agd-servico-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid #f4f4f5;
}

.agd-servico-item:hover {
    background: #f0f4ff;
}

.agd-servico-item:last-child {
    border-bottom: none;
}

.agd-servico-info {
    flex: 1;
    min-width: 0;
}

.agd-servico-nome {
    font-weight: 600;
    font-size: 13px;
    color: #2c3e50;
}

.agd-servico-tempo {
    font-size: 11px;
    color: #7f8c8d;
    margin-top: 1px;
}

.agd-servico-preco {
    font-weight: 700;
    font-size: 13px;
    color: #43b581;
    white-space: nowrap;
    margin-left: 12px;
}

/* ============ MOBILE ============ */
@media (max-width: 768px) {
    .agendamento-modal-header {
        padding: 12px 16px;
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
    }

    .agendamento-modal-header .modal-title {
        font-size: 1rem;
    }

    .agendamento-modal-body {
        padding: 10px 12px;
        /* Em fullscreen mobile o customModal ja faz 100vh, body precisa preencher */
        -webkit-overflow-scrolling: touch;
    }

    .agd-section {
        padding: 10px;
        margin-bottom: 8px;
        border-radius: 6px;
    }

    .agd-section-title {
        font-size: 11px;
        margin-bottom: 6px;
    }

    /* Campos empilham verticalmente */
    .agd-row {
        flex-direction: column;
        gap: 8px;
    }

    .agd-field.agd-sm,
    .agd-field.agd-md {
        flex: 1;
    }

    .agd-label {
        font-size: 10px;
    }

    /* Touch targets minimo 44px */
    .agd-field select,
    .agd-field input {
        padding: 10px 12px;
        font-size: 16px; /* evita zoom no iOS */
        min-height: 44px;
    }

    /* Alerta menor */
    .agd-alert-gcal {
        font-size: 10px;
        padding: 5px 10px;
    }

    /* Tabela servicos: esconder header, cards empilhados */
    .agd-servicos-table thead {
        display: none;
    }

    .agd-servicos-table tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid #f1f3f5;
    }

    .agd-servicos-table tr:last-child {
        border-bottom: none;
    }

    .agd-servicos-table td {
        border: none;
        padding: 2px 4px;
    }

    .agd-servicos-table td:first-child {
        flex: 1;
        font-weight: 600;
        font-size: 13px;
    }

    .agd-servicos-table .agd-col-tempo {
        font-size: 11px;
        color: #7f8c8d;
    }

    .agd-servicos-table .agd-col-valor {
        font-size: 13px;
        font-weight: 600;
    }

    .agd-servicos-total {
        gap: 14px;
        font-size: 14px;
    }

    /* Botao remover maior para touch */
    .agd-btn-remover {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    /* Footer */
    .agendamento-modal-footer {
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        flex-wrap: wrap;
    }

    .agendamento-modal-footer .agd-btn {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px;
    }

    /* Botoes ocupam largura total em tela pequena */
    .agendamento-modal-footer > div:last-child {
        flex: 1;
        display: flex;
        gap: 8px;
    }

    .agendamento-modal-footer > div:last-child .agd-btn {
        flex: 1;
        justify-content: center;
    }

    /* Observacao */
    .agd-section input[type="text"] {
        font-size: 16px;
        min-height: 44px;
    }
}

/* Telas muito pequenas (< 375px) */
@media (max-width: 374px) {
    .agendamento-modal-body {
        padding: 8px;
    }

    .agd-section {
        padding: 8px;
        margin-bottom: 6px;
    }

    .agendamento-modal-footer .agd-btn {
        padding: 8px 10px;
        font-size: 12px;
    }
}
