/**
 * Vitatrellis Web Application Styles
 */

:root {
    --header-height: 64px;
    --header-height-tablet: 48px;
    --header-height-mobile: 44px;
    --primary-color: #0a7a3a;
    --primary-dark: #085a2a;
}

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

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; 
    background: #f5f5f5;
    color: #333; 
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
.header {
    background: #0a7a3a;
    color: #fff;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    text-decoration: none;
    color: #fff;
}

/* Mobile Menu Toggle (Hamburger) */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin-right: 8px;
}

.hamburger-icon {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    position: relative;
}

.hamburger-icon::before,
.hamburger-icon::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 2px;
    background: #fff;
    left: 0;
}

.hamburger-icon::before {
    top: -7px;
}

.hamburger-icon::after {
    top: 7px;
}

/* Hamburger animation when menu is open */
.mobile-menu-toggle.active .hamburger-icon {
    background: transparent;
}

.mobile-menu-toggle.active .hamburger-icon::before {
    transform: rotate(45deg);
    top: 0;
}

.mobile-menu-toggle.active .hamburger-icon::after {
    transform: rotate(-45deg);
    top: 0;
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-link {
    color: #fff;
    text-decoration: none;
    font-size: 15px;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.2s;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.15);
}

.auth-links {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-email {
    color: rgba(255,255,255,0.9);
    font-size: 14px;
}

.logout-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.25);
}

.lang-switch {
    display: flex;
    gap: 6px;
}

.lang-btn {
    padding: 4px 10px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    transition: background 0.2s;
}

.lang-btn:hover {
    background: rgba(255,255,255,0.25);
}

.lang-btn.active {
    background: rgba(255,255,255,0.3);
    font-weight: 600;
}

/* Language Dropdown Styles */
.lang-dropdown {
    position: relative;
    display: inline-block;
}

.lang-dropdown-btn {
    padding: 6px 14px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.lang-dropdown-btn:hover {
    background: rgba(255,255,255,0.25);
}

.lang-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 140px;
    z-index: 1000;
    overflow: hidden;
}

.lang-dropdown.open .lang-dropdown-menu {
    display: block;
}

.lang-dropdown-item {
    display: block;
    padding: 10px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}

.lang-dropdown-item:hover {
    background: #e8f5e9;
}

.lang-dropdown-item.active {
    background: #e8f5e9;
    color: #0a7a3a;
    font-weight: 500;
}

/* Main App Container - 3 Column Layout for Desktop */
.app-container {
    display: grid;
    grid-template-columns: minmax(180px, 260px) minmax(240px, 280px) 1fr;
    height: calc(100vh - var(--header-height));
}

/* Menu Column */
.menu-column {
    background: #fff;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    min-width: 180px;
    max-width: 260px;
}

/* Sidebar (Task List Column) */
.sidebar {
    width: 100%;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.add-task-btn {
    background: #0a7a3a;
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.add-task-btn:hover {
    background: #085a2a;
}

/* Menu Items */
.menu-section {
    padding: 12px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.15s;
    color: #333;
    text-decoration: none;
}

.menu-item:hover {
    background: #f5f5f5;
}

.menu-item.active {
    background: #e8f5e9;
    color: #0a7a3a;
    font-weight: 500;
}

.menu-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.menu-item.coming-soon {
    color: #999;
}

.menu-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.menu-label {
    flex: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.menu-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #0a7a3a;
    color: #fff;
}

.menu-badge.coming-soon {
    /* Hide the coming soon badge visually but keep it accessible to screen readers */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Hover tooltip for coming soon menu items - visual enhancement for mouse users
   Note: The .menu-badge.coming-soon element is still present for screen reader accessibility */
.menu-item.coming-soon {
    position: relative;
}

.menu-item.coming-soon::after {
    content: attr(data-tooltip);
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: #666;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 10;
}

.menu-item.coming-soon:hover::after,
.menu-item.coming-soon:focus::after,
.menu-item.coming-soon:focus-within::after {
    opacity: 1;
    visibility: visible;
}

/* Task List */
.task-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.task-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.15s;
    border-left: 3px solid transparent;
}

.task-item:hover {
    background: #f8f8f8;
}

.task-item.selected {
    background: #e8f5e9;
    border-left-color: #0a7a3a;
}

.task-item.completed {
    opacity: 0.6;
}

.task-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-top: 2px;
}

.task-checkbox:hover {
    border-color: #0a7a3a;
}

.task-checkbox.checked {
    background: #0a7a3a;
    border-color: #0a7a3a;
    color: #fff;
}

.task-content {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
    word-break: break-word;
}

.task-item.completed .task-title {
    text-decoration: line-through;
    color: #888;
}

.task-due {
    font-size: 12px;
    color: #888;
}

.task-due.overdue {
    color: #dc3545;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
}

/* Task Detail Panel */
.task-detail {
    padding: 32px;
    flex: 1;
    overflow-y: auto;
}

.task-detail.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 16px;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.detail-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.detail-actions {
    display: flex;
    gap: 8px;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    margin-bottom: 6px;
}

.form-group input, 
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus, 
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #0a7a3a;
    box-shadow: 0 0 0 3px rgba(10, 122, 58, 0.1);
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #0a7a3a;
    color: #fff;
}

.btn-primary:hover {
    background: #085a2a;
}

.btn-secondary {
    background: #e9ecef;
    color: #495057;
}

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

.btn-danger {
    background: #dc3545;
    color: #fff;
}

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

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

/* Login/Register Forms */
.auth-container {
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #e8f5e9 0%, #f5f5f5 100%);
}

.auth-card {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 420px;
}

.auth-card h1 {
    color: #064;
    font-size: 28px;
    margin-bottom: 8px;
    text-align: center;
}

.auth-card .subtitle {
    color: #666;
    text-align: center;
    margin-bottom: 32px;
}

.auth-card .form-group input {
    padding: 12px 16px;
}

.auth-card .btn-primary {
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: #666;
}

.auth-footer a {
    color: #0a7a3a;
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Alert Messages */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

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

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

/* Loading States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #888;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e0e0e0;
    border-top-color: #0a7a3a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 12px;
}

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

/* Connection Status */
.connection-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    transition: transform 0.3s, opacity 0.3s;
}

.connection-status.hidden {
    transform: translateY(100px);
    opacity: 0;
}

.connection-status.connected {
    background: #d4edda;
    color: #155724;
}

.connection-status.disconnected {
    background: #f8d7da;
    color: #721c24;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.connected .status-dot {
    background: #28a745;
}

.disconnected .status-dot {
    background: #dc3545;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-20px);
    transition: transform 0.2s;
}

.modal-overlay.visible .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #888;
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover {
    color: #333;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.mobile-menu-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Floating Action Button for Feedback (Mobile) */
.fab-feedback {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #0a7a3a;
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 80;
    transition: transform 0.2s, box-shadow 0.2s;
}

.fab-feedback:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}

.fab-feedback:active {
    transform: scale(0.95);
}

.fab-icon {
    font-size: 24px;
}

/* Desktop Feedback visibility */
.desktop-feedback {
    display: flex;
}

/* Mobile Auth Section in Menu (hidden on desktop) */
.mobile-auth-section {
    display: none;
    border-bottom: 1px solid #e0e0e0;
    padding: 12px 0;
}

.mobile-auth-link {
    text-decoration: none;
}

/* Tablet Responsive (901px - 1024px) */
@media (min-width: 901px) and (max-width: 1024px) {
    .app-container {
        grid-template-columns: minmax(160px, 200px) minmax(200px, 240px) 1fr;
    }
    
    .menu-column {
        min-width: 160px;
        max-width: 200px;
    }
}

/* Tablet/Mobile - Single Column Layout */
@media (max-width: 900px) {
    .app-container {
        display: flex;
        flex-direction: column;
        height: calc(100vh - var(--header-height-tablet));
    }
    
    .menu-column {
        display: none;
        position: fixed;
        top: var(--header-height-tablet);
        left: 0;
        width: 280px;
        height: calc(100vh - var(--header-height-tablet));
        z-index: 95;
        box-shadow: 2px 0 8px rgba(0,0,0,0.2);
    }
    
    .menu-column.visible {
        display: block;
    }
    
    .mobile-menu-overlay {
        display: block;
        top: var(--header-height-tablet);
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    /* Mobile: Sidebar fills remaining space when no task is selected */
    .sidebar {
        flex: 1;
        border-right: none;
        border-bottom: none;
        max-height: none;
        min-height: 0;
    }
    
    /* Mobile: Hide main content when no task is selected */
    .main-content {
        display: none;
    }
    
    .header {
        padding: 12px 16px;
    }
    
    .nav-links {
        display: none;
    }
    
    .desktop-feedback {
        display: none;
    }
    
    .fab-feedback {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Show mobile auth section in menu */
    .mobile-auth-section {
        display: block;
    }
    
    /* Hide header auth links on mobile */
    .header .auth-links .auth-guest {
        display: none !important;
    }
    
    /* Hide header logout button on mobile */
    .header .auth-links .logout-btn {
        display: none !important;
    }
    
    /* Style mobile logout button in menu */
    .mobile-logout-btn {
        cursor: pointer;
        color: #dc3545;
    }
    
    .mobile-logout-btn:hover {
        background: #f8d7da;
    }
}

/* Mobile Responsive (< 768px) */
@media (max-width: 768px) {
    .header {
        padding: 10px 12px;
    }
    
    .header-left, .header-right {
        gap: 12px;
    }
    
    .logo {
        font-size: 20px;
    }
    
    .menu-column {
        top: var(--header-height-mobile);
        height: calc(100vh - var(--header-height-mobile));
    }
    
    .mobile-menu-overlay {
        top: var(--header-height-mobile);
    }
    
    .app-container {
        height: calc(100vh - var(--header-height-mobile));
    }
    
    .task-detail {
        padding: 20px;
    }
    
    .detail-header {
        flex-direction: column;
        gap: 16px;
    }
    
    .detail-title {
        font-size: 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .auth-card {
        padding: 24px;
    }
    
    .user-email {
        display: none !important;
    }
    
    .fab-feedback {
        bottom: 20px;
        right: 20px;
    }
}

/* Very Small Screens */
@media (max-width: 480px) {
    .header {
        padding: 8px 10px;
    }
    
    .logo {
        font-size: 18px;
    }
    
    .lang-switch {
        gap: 4px;
    }
    
    .lang-btn {
        padding: 3px 8px;
        font-size: 12px;
    }
    
    .sidebar-header {
        padding: 12px 16px;
    }
    
    .sidebar-title {
        font-size: 16px;
    }
    
    .task-item {
        padding: 10px 16px;
    }
    
    .menu-item {
        padding: 10px 16px;
    }
}

/* Mobile Back Button Styles */
.mobile-back-btn {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #0a7a3a;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.2s;
}

.mobile-back-btn:hover {
    background: #085a2a;
}

.back-arrow {
    font-size: 18px;
}

/* Mobile Fullscreen Task View (screen width <= 900px) */
@media (max-width: 900px) {
    /* When viewing a task on mobile, hide sidebar and show task fullscreen */
    .app-container.mobile-task-view .sidebar {
        display: none;
    }
    
    /* Show main content when a task is selected (overrides default mobile hidden state) */
    .app-container.mobile-task-view .main-content {
        display: flex;
        min-height: calc(100vh - var(--header-height-tablet));
        flex: 1;
    }
    
    .app-container.mobile-task-view .mobile-back-btn {
        display: flex;
    }
}

@media (max-width: 768px) {
    .app-container.mobile-task-view .main-content {
        min-height: calc(100vh - var(--header-height-mobile));
    }
}

/* Turnstile CAPTCHA Container */
.turnstile-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.turnstile-container .cf-turnstile {
    margin: 0 auto;
}
