/* Reset e Variáveis */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #DC143C;
    --primary-dark: #B01030;
    --primary-light: #FF4757;
    --white: #FFFFFF;
    --bg-gray: #F5F5F5;
    --text-dark: #333333;
    --text-light: #666666;
    --border-color: #E0E0E0;
    --success: #28A745;
    --warning: #FFC107;
    --danger: #DC3545;
    --info: #17A2B8;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-gray);
    color: var(--text-dark);
    line-height: 1.6;
}

/* Telas */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Login Screen */
#loginScreen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    padding: 20px;
}

.login-container {
    background: var(--white);
    border-radius: 16px;
    padding: 40px;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

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

.login-header i {
    font-size: 60px;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.login-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.login-header p {
    color: var(--text-light);
    font-size: 16px;
}

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

.login-form .form-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.login-form input {
    width: 100%;
    padding: 15px 15px 15px 45px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.login-info {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-gray);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-light);
}

.login-info strong {
    color: var(--text-dark);
}

/* Header */
.app-header {
    background: var(--white);
    box-shadow: var(--shadow);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 70px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--primary-color);
    cursor: pointer;
    padding: 10px;
}

.app-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-name {
    font-weight: 500;
    color: var(--text-dark);
}

.btn-icon {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-light);
    cursor: pointer;
    padding: 8px;
    transition: color 0.3s;
}

.btn-icon:hover {
    color: var(--primary-color);
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: -280px;
    top: 70px;
    bottom: 0;
    width: 280px;
    background: var(--white);
    box-shadow: var(--shadow);
    transition: left 0.3s;
    z-index: 999;
    overflow-y: auto;
}

.sidebar.open {
    left: 0;
}

.menu-list {
    list-style: none;
    padding: 20px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px 25px;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s;
}

.menu-item:hover {
    background: var(--bg-gray);
    color: var(--primary-color);
}

.menu-item.active {
    background: var(--primary-color);
    color: var(--white);
    border-left: 4px solid var(--primary-dark);
}

.menu-item i {
    font-size: 20px;
    width: 24px;
}

/* Main Content */
.main-content {
    margin-top: 70px;
    padding: 20px;
    min-height: calc(100vh - 70px);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    text-align: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 18px;
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #218838;
}

.btn-warning {
    background: var(--warning);
    color: var(--text-dark);
}

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

.btn-secondary {
    background: var(--text-light);
    color: var(--white);
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title i {
    color: var(--primary-color);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

/* Estilos para Formulário de Abastecimento Melhorado */
/* CORREÇÃO v1.5.6: Modais iniciam OCULTOS */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none; /* CORREÇÃO: inicialmente oculto */
    align-items: center;
    justify-content: center;
    z-index: 10000;
    overflow: auto;
    padding: 20px;
}

/* Quando o modal está ativo */
.modal.active {
    display: flex;
}

/* Modal Overlay - Controle de interação */
.modal-overlay {
    pointer-events: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    pointer-events: all;
    opacity: 1;
}

.modal .modal-content {
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal .card {
    margin: 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-radius: 12px 12px 0 0;
}

.modal .card-header .card-title {
    margin: 0;
    color: white;
    font-size: 20px;
}

.btn-close-modal:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

/* Form Sections */
.form-section {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary-color);
}

.form-section h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Input Enhancements */
.form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

.form-control.error {
    border-color: #dc3545;
}

.form-control.success {
    border-color: #28a745;
}

/* Info Cards */
.info-card {
    background: white;
    padding: 12px;
    border-radius: 8px;
    margin-top: 10px;
    text-align: center;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Alert Styles */
.alert {
    padding: 12px 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    margin-bottom: 15px;
}

.alert i {
    font-size: 16px;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Responsive Improvements */
@media (max-width: 768px) {
    .modal .modal-content {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .modal .card {
        border-radius: 0;
    }
    
    .modal .card-header {
        border-radius: 0;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons button {
        width: 100% !important;
    }
}

@media (max-width: 480px) {
    .modal {
        padding: 0;
    }
    
    .modal .card-header .card-title {
        font-size: 16px;
    }
}

/* Checkbox Group */
.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.checkbox-item:hover {
    background: var(--bg-gray);
}

.checkbox-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.checkbox-item label {
    cursor: pointer;
    margin: 0;
    flex: 1;
}

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

.stat-card {
    background: var(--white);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--white);
}

.stat-icon.red { background: var(--primary-color); }
.stat-icon.green { background: var(--success); }
.stat-icon.yellow { background: var(--warning); }
.stat-icon.blue { background: var(--info); }

.stat-info h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.stat-info p {
    color: var(--text-light);
    font-size: 14px;
}

/* Table */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

.table thead {
    background: var(--bg-gray);
}

.table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--text-dark);
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background: var(--bg-gray);
}

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

.badge-success { background: #D4EDDA; color: #155724; }
.badge-warning { background: #FFF3CD; color: #856404; }
.badge-danger { background: #F8D7DA; color: #721C24; }
.badge-info { background: #D1ECF1; color: #0C5460; }

/* Alert */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success { background: #D4EDDA; color: #155724; border-left: 4px solid #28A745; }
.alert-warning { background: #FFF3CD; color: #856404; border-left: 4px solid #FFC107; }
.alert-danger { background: #F8D7DA; color: #721C24; border-left: 4px solid #DC3545; }
.alert-info { background: #D1ECF1; color: #0C5460; border-left: 4px solid #17A2B8; }

/* Error Message */
.error-message {
    color: var(--danger);
    font-size: 14px;
    margin-top: 10px;
    display: none;
}

.error-message.show {
    display: block;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.loading i {
    font-size: 48px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 10px;
}

/* Image Preview */
.image-preview {
    margin-top: 15px;
    max-width: 300px;
}

.image-preview img {
    width: 100%;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

/* CRLV Upload Box */
.crlv-upload-box {
    width: 100%;
    height: 160px;
    background: #f5f5f5;
    border: 2px dashed #3b82f6;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    flex-direction: column;
    text-align: center;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.crlv-upload-box:hover {
    background: #eef6ff;
    border-color: #2563eb;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--text-light);
}

.upload-placeholder i {
    font-size: 48px;
    color: var(--primary-color);
}

.upload-placeholder p {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-dark);
    margin: 0;
}

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

.crlv-preview {
    max-width: 100%;
    width: 100%;
    border-radius: 8px;
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.crlv-preview:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

.upload-progress {
    padding: 20px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    border-radius: 10px;
    transition: width 0.3s ease;
}

.upload-progress small {
    display: block;
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        padding: 0 15px;
    }

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

    .user-name {
        display: none;
    }

    .main-content {
        padding: 15px;
    }

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

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

    .card {
        padding: 15px;
    }

    .table-container {
        font-size: 14px;
    }

    .table th, .table td {
        padding: 10px;
    }

    .login-container {
        padding: 30px 20px;
    }
}

@media (max-width: 480px) {
    .app-title span {
        display: none;
    }

    .checkbox-group {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.hidden { display: none !important; }
