:root {
    --primary-blue: #2196F3;
    --success-green: #4CAF50;
    --warning-yellow: #FFC107;
    --danger-red: #F44336;
    --accent-purple: #9C27B0;
    --background: #f8f9fa;
    --surface: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border: #e9ecef;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.15);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    padding-bottom: 80px;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #1976d2 0%, #1565c0 50%, #0d47a1 100%);
    color: white;
    padding: 2rem 1rem 1.25rem 1rem;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.app-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0%, transparent 50%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
}

.app-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    letter-spacing: 0.3px;
    position: relative;
    z-index: 1;
}

.app-header p {
    opacity: 0.9;
    font-size: 0.9rem;
    position: relative;
    z-index: 1;
}

/* Logo */
.app-logo {
    width: 120px;
    height: auto;
    display: block;
    margin: 0 auto 0.5rem auto;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2));
    position: relative;
    z-index: 1;
}

/* Main Content */
.app-main {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.app-section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.app-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.welcome-card, .config-card {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    text-align: center;
}

/* Professional polish */
.schedule-card, .alert-card, .modal-content, .faq-item {
    border: 1px solid rgba(233, 236, 239, 0.8);
}

.section-header h2 i {
    color: var(--primary-blue);
}

.primary-btn i, .secondary-btn i, .danger-btn i {
    opacity: 0.95;
}

/* Nav icons a bit crisper */
.bottom-nav i {
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.05));
}

.welcome-card h2 {
    color: var(--primary-blue);
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
}

.welcome-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Buttons */
.primary-btn, .secondary-btn, .danger-btn {
    border: none;
    border-radius: var(--border-radius);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-size: 0.9rem;
}

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

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

.secondary-btn {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.secondary-btn:hover {
    background: var(--background);
    transform: translateY(-1px);
}

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

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

.full-width {
    width: 100%;
    justify-content: center;
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    color: var(--primary-blue);
    font-size: 1.3rem;
}

/* Schedules */
.recent-schedules h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.schedules-list, .schedules-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

@media (max-width: 480px) {
    .schedules-list, .schedules-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

.schedule-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(25, 118, 210, 0.1);
    position: relative;
    overflow: hidden;
}

@media (max-width: 480px) {
    .schedule-card {
        padding: 1rem;
        border-radius: 12px;
    }
}

.schedule-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #1976d2, #42a5f5);
    border-radius: 16px 16px 0 0;
}

.schedule-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(25, 118, 210, 0.15);
    border-color: rgba(25, 118, 210, 0.2);
}

/* Schedule header removed - using linear layout */

.schedule-title {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    line-height: 1.3;
    padding-top: 0.5rem;
}

.schedule-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

@media (max-width: 480px) {
    .schedule-meta {
        font-size: 0.8rem;
        gap: 0.2rem;
        margin-bottom: 0.5rem;
    }
}

.schedule-regime {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, rgba(25, 118, 210, 0.1) 0%, rgba(66, 165, 245, 0.1) 100%);
    color: var(--primary-blue);
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(25, 118, 210, 0.2);
    margin-bottom: 0.75rem;
    width: fit-content;
}

@media (max-width: 480px) {
    .schedule-regime {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
        gap: 0.3rem;
    }
}

.schedule-regime::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--primary-blue);
    border-radius: 50%;
    flex-shrink: 0;
}

.schedule-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .schedule-actions {
        gap: 0.5rem;
        margin-top: 1rem;
        justify-content: stretch;
    }
    
    .schedule-actions .action-btn {
        flex: 1;
        min-width: 0;
        justify-content: center;
        padding: 0.5rem 0.4rem;
        font-size: 0.75rem;
    }
}

.action-btn {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid rgba(25, 118, 210, 0.2);
    color: var(--primary-blue);
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.action-btn:hover {
    background: linear-gradient(135deg, #e3f2fd 0%, #f8f9fa 100%);
    border-color: rgba(25, 118, 210, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.15);
}

.action-btn:hover::before {
    left: 100%;
}

/* Filters */
.filters-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-select, .search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--surface);
    font-size: 0.9rem;
}

.search-input {
    background: var(--surface) url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="%236c757d" viewBox="0 0 16 16"><path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/></svg>') no-repeat right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Alerts */
.alerts-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.alert-card {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
}

.alert-card.urgent {
    border-left: 4px solid var(--danger-red);
}

.alert-card.warning {
    border-left: 4px solid var(--warning-yellow);
}

.alert-card.info {
    border-left: 4px solid var(--primary-blue);
}

.alert-card i { display: none; }

.alert-card.urgent i {
    color: var(--danger-red);
}

.alert-card.warning i {
    color: var(--warning-yellow);
}

.alert-card.info i {
    color: var(--primary-blue);
}

.alert-card h4 {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}

.alert-card span {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-item {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-blue);
}

.alert-item.urgent {
    border-left-color: var(--danger-red);
}

.alert-item.warning {
    border-left-color: var(--warning-yellow);
}

/* Configuration */
.config-sections {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.config-card {
    text-align: left;
}

.config-card h3 {
    color: var(--primary-blue);
    margin-bottom: 1rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.config-item {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.config-item label {
    font-weight: 500;
    color: var(--text-primary);
}

.config-input, .config-select {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--surface);
    font-size: 0.9rem;
}

.toggle-switch {
    width: 50px;
    height: 24px;
    appearance: none;
    background: var(--border);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-switch:checked {
    background: var(--success-green);
}

.toggle-switch::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch:checked::before {
    transform: translateX(26px);
}

/* FAQ */
.faq-section {
    margin: 2rem 0;
}

.faq-section h2 {
    color: var(--primary-blue);
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.3rem;
}

.faq-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.faq-item {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.faq-question {
    width: 100%;
    padding: 1rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--transition);
}

.faq-question:hover {
    background: var(--background);
}

.faq-question[aria-expanded="true"] {
    background: var(--primary-blue);
    color: white;
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(45deg);
}

.faq-icon {
    font-size: 1.2rem;
    font-weight: 300;
    transition: var(--transition);
}

.faq-answer {
    padding: 0 1rem 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.faq-answer[hidden] {
    display: none;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1rem;
}

.modal.active {
    display: flex;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--surface);
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: var(--primary-blue);
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--background);
    color: var(--text-primary);
}

.modal-body {
    padding: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input, .form-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--surface);
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 0.5rem 0.5rem;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-secondary);
    padding: 0.35rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    min-width: 52px;
}

.nav-item i {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 0.1rem;
}

.nav-item span {
    font-size: 0.78rem;
    font-weight: 600;
}

.nav-item.active {
    color: var(--primary-blue);
    background: rgba(33, 150, 243, 0.1);
}

.nav-item:hover {
    color: var(--primary-blue);
    background: rgba(33, 150, 243, 0.05);
}

/* underline indicator for active nav */
.nav-item.active::after {
    content: '';
    display: block;
    width: 18px;
    height: 3px;
    border-radius: 3px;
    background: var(--primary-blue);
    margin-top: 2px;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 1rem 1rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 2rem;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.footer-links {
    display: flex;
    gap: 0.5rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px dotted transparent;
}

.footer-links a:hover {
    color: var(--primary-blue);
    border-bottom-color: var(--primary-blue);
}

/* Legal Pages Styling */
.welcome-card h2 {
    color: var(--primary-blue);
    margin-bottom: 1rem;
    font-size: 1.3rem;
    border-bottom: 2px solid rgba(25, 118, 210, 0.1);
    padding-bottom: 0.5rem;
}

.welcome-card ul {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.welcome-card li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.welcome-card p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

.welcome-card strong {
    color: var(--text-primary);
    font-weight: 600;
}

.welcome-card a {
    color: var(--primary-blue);
    text-decoration: none;
    border-bottom: 1px solid rgba(25, 118, 210, 0.3);
    transition: all 0.3s ease;
}

.welcome-card a:hover {
    color: #1565c0;
    border-bottom-color: var(--primary-blue);
    background-color: rgba(25, 118, 210, 0.05);
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
}

/* Regime badges */
.regime-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
}

.regime-badge.simples {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-green);
}

.regime-badge.lucro-presumido {
    background: rgba(255, 193, 7, 0.1);
    color: #F57C00;
}

.regime-badge.lucro-real {
    background: rgba(156, 39, 176, 0.1);
    color: var(--accent-purple);
}

/* Status indicators */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-indicator.active {
    background: var(--success-green);
}

.status-indicator.pending {
    background: var(--warning-yellow);
}

.status-indicator.overdue {
    background: var(--danger-red);
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Responsive Design */
@media (min-width: 768px) {
    .schedules-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }
    
    .config-sections {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 1.5rem;
    }
    
    .filters-bar {
        max-width: 600px;
    }
    
    .form-actions {
        justify-content: flex-end;
    }
    
    .config-item {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .config-item label {
        margin-bottom: 0;
        flex: 1;
    }
    
    .config-input, .config-select {
        max-width: 200px;
    }
}

@media (min-width: 1024px) {
    .app-main {
        padding: 2rem;
    }
    
    .bottom-nav {
        display: flex;
        gap: 2rem;
        padding: 0.75rem 1rem;
    }
    
    .nav-item {
        min-width: 80px;
    }
    
    .nav-item i {
        font-size: 1.1rem;
    }
    
    .nav-item span {
        font-size: 0.85rem;
    }
    
    body {
        padding-bottom: 80px;
    }
    
    /* Desktop navigation could be added here */
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus,
input:focus,
select:focus,
.nav-item:focus {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --shadow: 0 2px 10px rgba(0,0,0,0.3);
        --border: #666;
    }
}
