/* Toast Notification System */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid #2D5016;
}

.toast.success {
    border-left-color: #2e7d32;
}

.toast.error {
    border-left-color: #c62828;
}

.toast.warning {
    border-left-color: #ef6c00;
}

.toast.info {
    border-left-color: #1565c0;
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.toast-message {
    font-size: 14px;
    color: #666;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-close:hover {
    color: #333;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.removing {
    animation: slideOut 0.3s ease-out forwards;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Form Validation Styles */
.form-group input.error,
.form-group select.error {
    border-color: #c62828;
}

.form-group input.success,
.form-group select.success {
    border-color: #2e7d32;
}

.error-message {
    color: #c62828;
    font-size: 12px;
    margin-top: 4px;
    display: none;
}

.error-message.show {
    display: block;
}

/* Improved Mobile Styles */
@media (max-width: 768px) {
    .toast-container {
        left: 10px;
        right: 10px;
        max-width: none;
    }
    
    .dashboard-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        padding: 16px;
    }
    
    .sidebar h2 {
        margin-bottom: 16px;
    }
    
    .nav-menu {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 8px;
    }
    
    .nav-menu li {
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .nav-menu a {
        padding: 8px 16px;
        white-space: nowrap;
    }
    
    .user-info {
        display: none;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .page-header h1 {
        font-size: 24px;
    }
    
    .modal-content {
        padding: 24px;
    }
    
    .fields-grid {
        grid-template-columns: 1fr;
    }
    
    .activity-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .activity-cost {
        align-self: flex-end;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-value {
        font-size: 28px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

/* Search and Filter Styles */
.search-bar {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
}

.search-input:focus {
    outline: none;
    border-color: var(--farm-green);
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}

.clear-search {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px;
    display: none;
}

.clear-search.show {
    display: block;
}

.clear-search:hover {
    color: #333;
}

/* Improved Empty States */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
}

/* Confirmation Dialog */
.confirm-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.confirm-dialog.show {
    display: flex;
}

.confirm-content {
    background: white;
    border-radius: 12px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.confirm-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.confirm-title {
    font-size: 20px;
    font-weight: 700;
    color: #333;
    margin-bottom: 12px;
}

.confirm-message {
    font-size: 14px;
    color: #666;
    margin-bottom: 24px;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.confirm-btn-cancel {
    background: #f5f5f5;
    color: #666;
}

.confirm-btn-cancel:hover {
    background: #e0e0e0;
}

.confirm-btn-confirm {
    background: #c62828;
    color: white;
}

.confirm-btn-confirm:hover {
    background: #b71c1c;
}

/* Accessibility Improvements */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid var(--farm-green);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .sidebar,
    .btn-add,
    .btn-icon,
    .logout-btn,
    .toast-container,
    .confirm-dialog {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
    }
    
    .dashboard-section {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
