/* ============================================
   FORNECEDORES - GESTÃO DE FORNECEDORES E COMPRAS
   ============================================ */

.fornecedores-page {
    padding: 0;
}

/* ============================================
   TOOLBAR
   ============================================ */
.fornecedores-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    background: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.fornecedores-toolbar-left {
    display: flex;
    gap: 12px;
    flex: 1;
    min-width: 200px;
    flex-wrap: wrap;
}

.fornecedores-search {
    flex: 1;
    max-width: 400px;
    min-width: 200px;
    position: relative;
}

.fornecedores-search input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: #fafafa;
}

.fornecedores-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
    background: white;
}

.fornecedores-search i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 16px;
}

.fornecedores-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 20px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #0056b3 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.2);
    white-space: nowrap;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.4);
}

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

/* ============================================
   CARDS DE FORNECEDORES
   ============================================ */
.fornecedores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.fornecedor-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    position: relative;
    border: 1px solid #f0f0f0;
    overflow: hidden;
}

.fornecedor-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary) 0%, #0056b3 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.fornecedor-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
    border-color: var(--primary);
}

.fornecedor-card:hover::before {
    opacity: 1;
}

.fornecedor-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    gap: 12px;
}

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

.fornecedor-nome {
    font-size: 18px;
    font-weight: 700;
    color: #1d1d1f;
    margin-bottom: 4px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fornecedor-categoria {
    font-size: 13px;
    color: #666;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.fornecedor-categoria i {
    color: var(--primary);
}

.fornecedor-status-badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.fornecedor-status-badge.ativo {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.fornecedor-status-badge.inativo {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
}

.fornecedor-contato {
    margin: 16px 0;
    padding: 12px 0;
    border-top: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
}

.fornecedor-contato-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 14px;
    color: #555;
}

.fornecedor-contato-item:last-child {
    margin-bottom: 0;
}

.fornecedor-contato-item i {
    width: 18px;
    color: var(--primary);
    flex-shrink: 0;
}

.fornecedor-contato-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fornecedor-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.fornecedor-stat {
    text-align: center;
    padding: 12px 8px;
    background: linear-gradient(135deg, #f9f9f9 0%, #f5f5f5 100%);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.fornecedor-stat:hover {
    background: linear-gradient(135deg, #f5f5f5 0%, #efefef 100%);
    transform: translateY(-2px);
}

.fornecedor-stat-label {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: 600;
}

.fornecedor-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #1d1d1f;
}

.fornecedor-stat-value.destaque {
    color: var(--primary);
}

.fornecedor-stat-value.negativo {
    color: #FF3B30;
}

.fornecedor-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
}

.btn-action {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 10px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-action:hover {
    background: #f9f9f9;
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.btn-action.comprar {
    background: linear-gradient(135deg, var(--primary) 0%, #0056b3 100%);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.2);
}

.btn-action.comprar:hover {
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.4);
}

.btn-action.pagar {
    background: linear-gradient(135deg, #34C759 0%, #28a745 100%);
    color: white;
    border-color: #34C759;
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.2);
}

.btn-action.pagar:hover {
    box-shadow: 0 4px 12px rgba(52, 199, 89, 0.4);
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 10000;
    animation: fadeIn 0.3s ease;
    padding: 20px;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    margin: auto;
}

.modal-header {
    padding: 24px 28px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    border-radius: 20px 20px 0 0;
}

.modal-title {
    font-size: 22px;
    font-weight: 700;
    color: #1d1d1f;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 18px;
    color: #666;
    flex-shrink: 0;
}

.modal-close:hover {
    background: #e0e0e0;
    transform: rotate(90deg);
}

.modal-body {
    padding: 28px;
}

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

.form-group {
    margin-bottom: 20px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
}

.form-label.required::after {
    content: "*";
    color: #FF3B30;
    margin-left: 4px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: #fafafa;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
    background: white;
}

.form-input.error {
    border-color: #FF3B30;
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.form-select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
    background: white;
}

.modal-footer {
    padding: 20px 28px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    position: sticky;
    bottom: 0;
    background: white;
    border-radius: 0 0 20px 20px;
    flex-wrap: wrap;
}

.btn-secondary {
    padding: 12px 24px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.btn-secondary:hover {
    background: #f9f9f9;
    transform: translateY(-2px);
}

/* ============================================
   HISTÓRICO DE COMPRAS
   ============================================ */
.historico-compras {
    margin-top: 24px;
}

.historico-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.historico-title {
    font-size: 16px;
    font-weight: 700;
    color: #1d1d1f;
}

.historico-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.compra-item {
    background: linear-gradient(135deg, #f9f9f9 0%, #f5f5f5 100%);
    padding: 16px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.compra-item:hover {
    background: linear-gradient(135deg, #f5f5f5 0%, #efefef 100%);
    border-color: var(--primary);
    transform: translateX(4px);
}

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

.compra-numero {
    font-size: 14px;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 4px;
}

.compra-data {
    font-size: 12px;
    color: #999;
}

.compra-valor {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin: 0 12px;
}

.compra-status {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.compra-status.pago {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.compra-status.pendente {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
}

.compra-status.parcial {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
}

/* ============================================
   ESTADO VAZIO
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 16px;
    border: 2px dashed #e0e0e0;
}

.empty-state i {
    font-size: 64px;
    color: #ccc;
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 20px;
    color: #555;
    margin-bottom: 12px;
    font-weight: 700;
}

.empty-state p {
    font-size: 14px;
    color: #999;
    margin-bottom: 24px;
    line-height: 1.6;
}

/* ============================================
   ANIMAÇÕES
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* ============================================
   RESPONSIVIDADE - TABLET
   ============================================ */
@media (max-width: 1024px) {
    .fornecedores-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* ============================================
   RESPONSIVIDADE - MOBILE
   ============================================ */
@media (max-width: 768px) {
    .fornecedores-toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }

    .fornecedores-toolbar-left {
        flex-direction: column;
        width: 100%;
    }

    .fornecedores-search {
        max-width: 100%;
        width: 100%;
    }

    .fornecedores-filters {
        width: 100%;
    }

    .filter-btn {
        flex: 1;
    }

    .fornecedores-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .fornecedor-card {
        padding: 20px;
    }

    .fornecedor-nome {
        font-size: 16px;
    }

    .fornecedor-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .fornecedor-stat {
        padding: 10px 6px;
    }

    .fornecedor-stat-label {
        font-size: 10px;
    }

    .fornecedor-stat-value {
        font-size: 14px;
    }

    .fornecedor-actions {
        flex-direction: column;
        gap: 10px;
    }

    .btn-action {
        width: 100%;
    }

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

    .modal {
        padding: 10px;
    }

    .modal-content {
        width: 100%;
        max-height: 95vh;
        border-radius: 16px;
    }

    .modal-header {
        padding: 20px;
        border-radius: 16px 16px 0 0;
    }

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

    .modal-body {
        padding: 20px;
    }

    .modal-footer {
        padding: 16px 20px;
        flex-direction: column-reverse;
    }

    .modal-footer .btn-primary,
    .modal-footer .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .compra-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .compra-valor {
        margin: 0;
    }
}

/* ============================================
   RESPONSIVIDADE - MOBILE PEQUENO
   ============================================ */
@media (max-width: 480px) {
    .fornecedores-toolbar {
        padding: 12px;
    }

    .fornecedores-filters {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        width: 100%;
        gap: 6px;
    }

    .filter-btn {
        font-size: 12px;
        padding: 8px 10px;
    }

    .btn-primary {
        padding: 10px 16px;
        font-size: 13px;
        width: 100%;
        justify-content: center;
    }

    .fornecedor-card {
        padding: 16px;
    }

    .fornecedor-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .fornecedor-status-badge {
        align-self: flex-start;
    }

    .fornecedor-contato-item {
        font-size: 13px;
    }

    .fornecedor-stats {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .fornecedor-stat {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px;
        text-align: left;
    }

    .fornecedor-stat-label {
        margin-bottom: 0;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }

    .modal-title {
        font-size: 16px;
    }

    .form-input,
    .form-select {
        font-size: 16px; /* Evita zoom no iOS */
    }
}

/* ============================================
   MELHORIAS DE ACESSIBILIDADE
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   AJUSTES PARA IMPRESSÃO
   ============================================ */
@media print {
    .fornecedores-toolbar,
    .fornecedor-actions,
    .modal-footer {
        display: none !important;
    }

    .fornecedores-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .fornecedor-card {
        break-inside: avoid;
    }
}
