/* ========================================
   SISTEMA DE FATURAÇÃO - CSS RESPONSIVO COMPLETO
   ======================================== */

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

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --dark-color: #1e293b;
    --light-color: #f8fafc;
    --gray-color: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

/* ========================================
   BASE STYLES
   ======================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f1f5f9;
    color: #334155;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   RESPONSIVE TYPOGRAPHY
   ======================================== */
html {
    font-size: 16px;
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
}

/* ========================================
   HEADER & NAVIGATION - RESPONSIVE
   ======================================== */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: bold;
    text-decoration: none;
    color: white;
}

.logo i {
    font-size: 24px;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}

/* Navigation */
nav ul {
    display: flex;
    list-style: none;
    gap: 5px;
    margin: 0;
    padding: 0;
}

nav ul li a {
    color: white;
    text-decoration: none;
    padding: 10px 15px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    font-size: 14px;
    white-space: nowrap;
}

nav ul li a:hover,
nav ul li a.active {
    background: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.15);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    white-space: nowrap;
}

.btn-logout {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

/* ========================================
   CONTAINER & LAYOUT
   ======================================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ========================================
   LOGIN PAGE - RESPONSIVE
   ======================================== */
.login-page {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 450px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: var(--shadow-lg);
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--dark-color);
    font-size: 28px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--gray-color);
    font-size: 13px;
}

/* ========================================
   FORMS - RESPONSIVE
   ======================================== */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

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

/* Form Row - Grid Responsivo */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    width: 100%;
}

/* ========================================
   BUTTONS - RESPONSIVE
   ======================================== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #64748b;
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

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

.btn-success:hover {
    background: #0da274;
}

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

.btn-info:hover {
    background: #2563eb;
}

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

.btn-danger:hover {
    background: #dc2626;
}

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

.btn-warning:hover {
    background: #eab308;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

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

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error,
.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ========================================
   CARDS - RESPONSIVE
   ======================================== */
.card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    transition: transform 0.3s;
}

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

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

.card-title {
    font-size: 22px;
    color: var(--dark-color);
    font-weight: 600;
}

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

.page-header h1 {
    color: var(--dark-color);
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ========================================
   TABLES - RESPONSIVE
   ======================================== */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border-radius: 8px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    min-width: 600px; /* Garantir largura mínima para scroll horizontal */
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--dark-color);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table tbody tr {
    transition: background 0.3s;
}

.table tbody tr:hover {
    background: #f8fafc;
}

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

/* ========================================
   STATS GRID - RESPONSIVE
   ======================================== */
.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: var(--shadow);
    text-align: center;
    transition: transform 0.3s;
}

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

.stat-card h3 {
    color: var(--gray-color);
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.stat-number {
    font-size: 36px;
    font-weight: bold;
    color: var(--primary-color);
    line-height: 1.2;
}

.stat-success {
    color: var(--success-color);
}

.stat-warning {
    color: var(--warning-color);
}

.stat-danger {
    color: var(--danger-color);
}

/* ========================================
   STATUS BADGES
   ======================================== */
.status-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    text-transform: capitalize;
}

.status-pendente {
    background: #fef3c7;
    color: #92400e;
}

.status-paga {
    background: #dcfce7;
    color: #166534;
}

.status-cancelada {
    background: #fee2e2;
    color: #991b1b;
}

.status-pendente-atraso {
    background: #fee2e2;
    color: #991b1b;
    animation: blink 2s infinite;
}

@keyframes blink {
    50% { opacity: 0.7; }
}

/* ========================================
   MODALS - RESPONSIVE
   ======================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow-y: auto;
    padding: 40px 20px;
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background-color: white;
    margin: 50px auto;
    padding: 30px;
    border-radius: 12px;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    animation: modalopen 0.3s;
    position: relative;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 900px;
}

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

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    color: #94a3b8;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close:hover {
    color: var(--dark-color);
    background: #f1f5f9;
}

/* ========================================
   DASHBOARD GRID - RESPONSIVE
   ======================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 20px;
}

/* ========================================
   FOOTER - RESPONSIVE
   ======================================== */
footer {
    background: var(--dark-color);
    color: white;
    text-align: center;
    padding: 25px 0;
    margin-top: 50px;
}

/* ========================================
   UTILITIES
   ======================================== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-10 {
    margin-top: 10px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* ========================================
   BREAKPOINTS - RESPONSIVE DESIGN
   ======================================== */

/* Tablet - até 1024px */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Mobile - até 768px */
@media (max-width: 768px) {
    /* Header Mobile */
    header .container {
        flex-direction: column;
        padding: 10px;
    }
    
    .logo {
        font-size: 18px;
    }
    
    .logo i {
        font-size: 20px;
    }
    
    /* Mobile Menu Toggle */
    .mobile-menu-toggle {
        display: block;
        position: absolute;
        right: 15px;
        top: 15px;
    }
    
    /* Navigation Mobile */
    nav ul {
        flex-direction: column;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        margin-top: 15px;
    }
    
    nav ul.show {
        max-height: 500px;
    }
    
    nav ul li {
        width: 100%;
    }
    
    nav ul li a {
        padding: 12px 20px;
        justify-content: flex-start;
    }
    
    /* User Menu Mobile */
    .user-menu {
        width: 100%;
        justify-content: space-between;
        margin-top: 15px;
    }
    
    .user-info {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    /* Container Mobile */
    .container {
        padding: 15px;
    }
    
    /* Page Header Mobile */
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .page-header h1 {
        font-size: 24px;
    }
    
    /* Buttons Mobile */
    .btn {
        padding: 12px 20px;
        font-size: 15px;
    }
    
    .btn-sm {
        padding: 8px 15px;
        font-size: 13px;
    }
    
    /* Cards Mobile */
    .card {
        padding: 20px 15px;
    }
    
    .card-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    /* Tables Mobile - Scroll Horizontal */
    .table-container {
        border-radius: 8px;
        overflow-x: auto;
    }
    
    .table {
        min-width: 800px; /* Ajustado para mobile */
    }
    
    /* Stats Grid Mobile */
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 20px 15px;
    }
    
    .stat-card h3 {
        font-size: 14px;
    }
    
    .stat-number {
        font-size: 32px;
    }
    
    /* Forms Mobile */
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 14px 12px;
        font-size: 16px; /* Melhor para touch */
    }
    
    .form-group label {
        font-size: 15px;
    }
    
    /* Login Box Mobile */
    .login-box {
        padding: 30px 20px;
    }
    
    .login-box h2 {
        font-size: 24px;
    }
    
    /* Modals Mobile */
    .modal-content {
        margin: 20px auto;
        padding: 20px 15px;
        width: 95%;
    }
    
    .modal-large {
        max-width: 100%;
    }
    
    /* Footer Mobile */
    footer {
        padding: 20px 10px;
        font-size: 14px;
    }
}

/* Mobile Pequeno - até 480px */
@media (max-width: 480px) {
    /* Fontes menores */
    html {
        font-size: 13px;
    }
    
    .page-header h1 {
        font-size: 20px;
    }
    
    .card-title {
        font-size: 18px;
    }
    
    /* Botões full width */
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .btn-group {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Login Box */
    .login-box {
        padding: 25px 15px;
    }
    
    /* Tabelas - Ajuste extra */
    .table {
        min-width: 600px;
        font-size: 13px;
    }
    
    .table th,
    .table td {
        padding: 10px 8px;
    }
    
    /* Stats */
    .stat-number {
        font-size: 28px;
    }
    
    .stat-card h3 {
        font-size: 13px;
    }
}

/* ========================================
   TOUCH OPTIMIZATIONS
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    /* Melhor para touch */
    .btn {
        min-height: 44px;
        padding: 12px 24px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        min-height: 44px;
    }
    
    .table tbody tr {
        cursor: pointer;
    }
    
    /* Aumentar área de toque para links */
    nav ul li a,
    .btn,
    .close {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    header,
    footer,
    .no-print,
    .mobile-menu-toggle {
        display: none !important;
    }
    
    body {
        background: white;
        padding: 0;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border-radius: 0;
        padding: 20px;
    }
    
    .table {
        width: 100%;
        border-collapse: collapse;
    }
    
    .table th,
    .table td {
        border: 1px solid #ddd;
    }
}