/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Professional universal color palette */
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --primary-light: #60A5FA;
    --secondary: #10B981;
    --accent: #F59E0B;
    --background: #F9FAFB;
    --card-bg: #FFFFFF;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;
    --border: #E5E7EB;
    --shadow: rgba(0, 0, 0, 0.1);
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: url('background.jpg') center center / cover fixed;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    position: relative;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    padding-bottom: 20px;
    position: relative;
    z-index: 1;
}

.screen.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

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

/* Login Screen */
#loginScreen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    position: relative;
    overflow: hidden;
}

#loginScreen.fade-out {
    animation: loginFadeOut 0.5s ease-out forwards;
}

@keyframes loginFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(1.1);
        display: none;
    }
}

#loginScreen.hidden {
    display: none !important;
}

.login-container {
    text-align: center;
    padding: 40px 30px;
    max-width: 400px;
    width: 90%;
    position: relative;
    z-index: 1;
    background: rgba(245, 245, 245, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.logo {
    margin-bottom: 30px;
    animation: fadeInScale 0.5s ease-out, float 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.login-container h1 {
    font-size: 32px;
    color: #1a1a1a;
    margin-bottom: 10px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.subtitle {
    color: #4a4a4a;
    font-size: 16px;
    margin-bottom: 40px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-form input {
    padding: 16px 20px;
    font-size: 18px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: white;
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.login-form input:focus {
    outline: none;
    background: white;
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.2);
    transform: translateY(-2px);
}

.login-form input:disabled {
    background: rgba(200, 200, 200, 0.5);
    cursor: not-allowed;
    border-color: #ccc;
}

.error-message {
    color: #dc2626;
    font-size: 14px;
    min-height: 20px;
    margin-top: -8px;
    animation: shake 0.5s ease-in-out;
}

.lockout-message {
    color: #dc2626;
    font-size: 16px;
    font-weight: 600;
    background: rgba(239, 68, 68, 0.1);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    margin-top: 12px;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Buttons */
.btn-primary {
    background: white;
    color: var(--primary);
    border: none;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

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

.btn-primary:disabled {
    background: rgba(200, 200, 200, 0.5);
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.btn-danger:hover {
    background: #DC2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    min-width: 44px;
    min-height: 44px;
}

.btn-icon:hover {
    background: rgba(37, 99, 235, 0.1);
    transform: scale(1.05);
}

.btn-icon:active {
    transform: scale(0.95);
}

/* App Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.app-header h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    text-align: center;
}

/* Property Cards */
.property-cards {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.property-card {
    background: linear-gradient(135deg, white 0%, #F9FAFB 100%);
    border-radius: 16px;
    padding: 28px 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 2px solid transparent;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.property-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.property-card:hover::before {
    transform: scaleX(1);
}

.property-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.15);
    border-color: var(--primary-light);
}

.property-card:active {
    transform: translateY(-4px);
}

.property-icon {
    color: var(--primary);
    margin-bottom: 16px;
    transition: transform 0.3s ease;
}

.property-card:hover .property-icon {
    transform: scale(1.1);
}

.property-card h3 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.receipt-count {
    font-size: 15px;
    color: var(--text-secondary);
}

/* Tab Bar */
.tab-bar {
    display: flex;
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    gap: 8px;
    position: sticky;
    top: 57px;
    z-index: 99;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tab-button {
    flex: 1;
    background: transparent;
    border: none;
    padding: 16px 12px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    min-height: 52px;
}

.tab-button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-button:hover {
    color: var(--primary-dark);
    background: rgba(37, 99, 235, 0.05);
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 8px;
    animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
    display: block;
}

/* Calendar */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 0 4px;
    gap: 8px;
}

.calendar-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    text-align: center;
}

.calendar-view-toggle {
    display: flex;
    gap: 4px;
    background: var(--background);
    border-radius: 8px;
    padding: 4px;
}

.view-toggle-btn {
    background: transparent;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.view-toggle-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 100px;
    padding: 0 2px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    background: white;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
    position: relative;
}

.calendar-day.header {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: default;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendar-day.other-month {
    color: var(--text-light);
    background: var(--background);
    border-color: transparent;
}

.calendar-day.today {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
    font-weight: 600;
}

.calendar-day.has-receipts {
    background: var(--primary-light);
    color: white;
    border-color: var(--primary);
    font-weight: 600;
}

.calendar-day.has-receipts::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

.calendar-day:not(.header):not(.other-month):hover {
    transform: scale(1.08);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
    z-index: 1;
}

/* Year View */
.year-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, auto);
    gap: 12px;
    margin-bottom: 100px;
    overflow-x: auto;
    padding: 4px;
}

.year-month {
    background: white;
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid transparent;
}

.year-month:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.15);
    border-color: var(--primary-light);
}

.year-month-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 8px;
}

.year-mini-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.year-mini-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-secondary);
    border-radius: 4px;
}

.year-mini-day.header {
    font-weight: 600;
    font-size: 9px;
    color: var(--text-light);
}

.year-mini-day.other-month {
    opacity: 0.3;
}

.year-mini-day.has-receipts {
    background: var(--primary-light);
    color: white;
    font-weight: 600;
}

/* Categories List */
.categories-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 100px;
}

.category-item {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 72px;
    border: 2px solid transparent;
}

.category-item:hover {
    transform: translateX(6px);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.12);
    border-color: var(--primary-light);
}

.category-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.category-icon {
    font-size: 28px;
    width: 40px;
    text-align: center;
}

.category-name {
    font-size: 17px;
    font-weight: 500;
    color: var(--text-primary);
}

.category-count {
    background: var(--primary-light);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 15px;
    font-weight: 600;
    min-width: 44px;
    text-align: center;
}

/* Summary */
.summary-container {
    margin-bottom: 100px;
}

.year-selector {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 0 8px;
}

.year-selector h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.summary-stats {
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

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

.stat-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-total {
    background: var(--primary);
    color: white;
    border-radius: 8px;
    padding: 6px 14px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.export-section {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.export-section h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.export-section button {
    margin-bottom: 12px;
}

.export-section button:last-child {
    margin-bottom: 0;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 50;
}

.fab:hover {
    transform: scale(1.15) rotate(90deg);
    box-shadow: 0 6px 28px rgba(37, 99, 235, 0.5);
}

.fab:active {
    transform: scale(1.1) rotate(90deg);
}

/* Receipt Gallery */
.receipt-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 20px;
}

.receipt-thumbnail {
    aspect-ratio: 3/4;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
}

.receipt-thumbnail:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.receipt-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.receipt-thumbnail .voice-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(37, 99, 235, 0.9);
    color: white;
    padding: 6px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.receipt-thumbnail .receipt-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    padding: 12px;
    color: white;
    font-size: 14px;
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: white;
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    margin: 20px auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

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

.close-modal {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#receiptImage {
    width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 400px;
    object-fit: contain;
    background: var(--background);
}

.receipt-details {
    padding: 24px;
}

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

.detail-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-group input,
.detail-group select,
.detail-group textarea {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--background);
    color: var(--text-primary);
    font-family: inherit;
    transition: all 0.2s ease;
}

.detail-group input:focus,
.detail-group select:focus,
.detail-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.detail-group textarea {
    resize: vertical;
    min-height: 80px;
}

.voice-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.voice-controls button {
    justify-content: center;
}

.voice-controls audio {
    width: 100%;
    height: 40px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions button {
    flex: 1;
}

/* Recording Animation */
.recording {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        background: var(--danger);
    }
    50% {
        background: #F87171;
    }
}

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

.empty-state svg {
    width: 80px;
    height: 80px;
    color: var(--text-light);
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 16px;
}

/* Responsive Design - Tablet */
@media (min-width: 768px) {
    .property-cards {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .property-card {
        flex: 1;
        min-width: 280px;
    }
    
    .receipt-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .calendar-grid {
        gap: 4px;
        padding: 0 8px;
    }
    
    .calendar-day {
        font-size: 18px;
    }
    
    .year-grid {
        grid-template-columns: repeat(6, 1fr);
        overflow-x: visible;
    }
}

/* Responsive Design - Desktop */
@media (min-width: 1024px) {
    .receipt-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .modal-content {
        max-width: 600px;
    }
    
    .calendar-grid {
        gap: 6px;
        padding: 0 12px;
    }
    
    .year-grid {
        grid-template-columns: repeat(6, 1fr);
        overflow-x: visible;
    }
}

/* Touch Feedback */
@media (hover: none) {
    .property-card:active {
        transform: scale(0.98);
    }
    
    .category-item:active {
        transform: scale(0.98);
    }
    
    .receipt-thumbnail:active {
        transform: scale(0.98);
    }
}
