/* Time Tracker - Styles
   Legion Software Inc.
*/

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Variables */
:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #dbeafe;
    --success: #059669;
    --success-light: #d1fae5;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #0284c7;
    --info-light: #e0f2fe;
    --bg: #f3f4f6;
    --card: #ffffff;
    --sidebar: #1f2937;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Layout */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    color: #9ca3af;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 4px;
    transition: all 0.15s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.main {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
}

.header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
}

.content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

/* Filter bars - Desktop defaults */
.entries-filter {
    display: flex;
    gap: 12px;
    align-items: center;
}

.entries-filter select,
.entries-filter input {
    width: 150px;
}

.analytics-filter {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
}

.analytics-filter input {
    width: 150px;
}

.filter-label {
    margin: 0;
    white-space: nowrap;
}

.stats-grid {
    margin-bottom: 24px;
}

.card-body {
    padding: 20px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

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

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

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

.btn-secondary {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-secondary:hover {
    background: var(--bg);
}

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

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

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

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.form-input:disabled,
.form-select:disabled {
    background: var(--bg);
    cursor: not-allowed;
}

/* Toggle Group */
.toggle-group {
    display: flex;
    gap: 8px;
}

.toggle-btn {
    flex: 1;
    padding: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.toggle-btn:hover:not(:disabled) {
    border-color: var(--primary);
}

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

/* Timer Display */
.timer-display {
    font-size: 64px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    text-align: center;
}

.timer-display.running {
    color: var(--success);
}

/* Category Badges */
.category-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 6px;
    text-transform: uppercase;
}

.category-badge.regular {
    background: var(--primary-light);
    color: var(--primary);
}

.category-badge.after-hours {
    background: var(--warning-light);
    color: #92400e;
}

.category-badge.weekend {
    background: #ede9fe;
    color: #6b21a8;
}

.category-badge.emergency {
    background: var(--danger-light);
    color: #991b1b;
}

/* Work Items */
.work-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

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

.work-item:hover {
    background: #f9fafb;
}

.work-item.completed {
    background: #f0fdf4;
}

.work-item.completed .item-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

.work-item.selected {
    background: #eff6ff;
}

.item-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.work-item.completed .item-checkbox,
.work-item.selected .item-checkbox {
    background: var(--success);
    border-color: var(--success);
}

.work-item.completed .item-checkbox::after,
.work-item.selected .item-checkbox::after {
    content: '✓';
    color: white;
    font-size: 12px;
}

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

.item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.item-title {
    font-weight: 500;
    margin-bottom: 2px;
    flex: 1;
    min-width: 0;
}

.item-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Expandable Tickets */
.work-item.expandable {
    flex-wrap: wrap;
    cursor: pointer;
}

.work-item.expandable .item-checkbox {
    cursor: pointer;
}

.expand-arrow {
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.expand-arrow:hover {
    background: var(--border);
    color: var(--text-primary);
}

.expand-arrow.expanded {
    color: var(--primary);
}

/* Ticket Conversation Panel */
.ticket-conversation {
    width: 100%;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.conversation-empty {
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
    padding: 8px 0;
}

.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comment-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
}

.comment-card.internal {
    background: #fffbeb;
    border-color: #fde68a;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.comment-author {
    font-weight: 600;
    color: var(--primary);
    font-size: 13px;
}

.comment-date {
    font-size: 12px;
    color: var(--text-muted);
}

.internal-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    background: #fef3c7;
    color: #92400e;
    text-transform: uppercase;
}

.comment-content {
    font-size: 13px;
    color: var(--text-primary);
    white-space: pre-wrap;
    line-height: 1.5;
}

/* Severity Badges */
.severity-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.severity-badge.critical {
    background: var(--danger-light);
    color: #991b1b;
}

.severity-badge.warning {
    background: var(--warning-light);
    color: #92400e;
}

.severity-badge.info {
    background: var(--info-light);
    color: #0369a1;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
}

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

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.visible {
    display: flex;
}

.modal {
    background: var(--card);
    border-radius: var(--radius-lg);
    width: 500px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    font-size: 18px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}

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

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-section {
    margin-bottom: 20px;
}

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

.modal-section h4 {
    font-size: 14px;
    font-weight: 600;
}

/* Ticket Confirmation Modal */
.ticket-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ticket-confirm-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
}

.ticket-info {
    margin-bottom: 8px;
}

.ticket-number {
    font-weight: 600;
    color: var(--primary);
    font-size: 13px;
}

.ticket-title {
    color: var(--text);
    margin-top: 2px;
}

.ticket-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ticket-status label {
    font-size: 13px;
    color: var(--text-secondary);
}

.ticket-status-select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--card);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 300;
}

.toast {
    background: var(--sidebar);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius);
    margin-top: 8px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 400px;
    max-width: 90%;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 24px;
    color: var(--primary);
}

/* Grid */
.grid {
    display: grid;
    gap: 24px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* Stats Card */
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Mobile Bottom Navigation */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--sidebar);
    z-index: 100;
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 10px;
    padding: 4px 0;
    gap: 2px;
    transition: color 0.2s;
}

.bottom-nav-item svg {
    width: 22px;
    height: 22px;
}

.bottom-nav-item.active {
    color: white;
}

.bottom-nav-item:hover {
    color: rgba(255,255,255,0.9);
}

/* Page Layouts - Desktop defaults */
.timer-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 32px;
}

.timesheet-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 32px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    .bottom-nav {
        display: flex;
        justify-content: space-around;
    }
    
    .main {
        margin-left: 0;
        padding-bottom: 80px;
    }
    
    .content {
        padding: 16px;
        padding-bottom: 20px;
    }
    
    .timer-display {
        font-size: 48px;
    }
    
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }
    
    /* Timer page - stack vertically */
    .timer-layout {
        display: flex;
        flex-direction: column;
        gap: 24px;
    }
    
    .timer-layout .timer-section {
        width: 100%;
    }
    
    .timer-layout .work-items-section {
        width: 100%;
    }
    
    /* Timesheets page - stack vertically */
    .timesheet-layout {
        display: flex;
        flex-direction: column;
        gap: 24px;
    }
    
    .timesheet-layout > * {
        width: 100%;
    }
    
    /* Analytics date picker - wrap on mobile */
    .analytics-filter {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .analytics-filter input[type="date"] {
        width: 100%;
        flex: 1;
        min-width: 140px;
    }
    
    .analytics-filter .btn {
        width: 100%;
    }
    
    /* Entries filter bar - stack on mobile */
    .entries-filter {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .entries-filter select,
    .entries-filter input {
        width: 100%;
        flex: 1;
        min-width: 120px;
    }
    
    /* Card header with filters - wrap on mobile */
    .card-header-flex {
        flex-direction: column;
        align-items: stretch;
    }
    
    .card-header-flex > span {
        margin-bottom: 8px;
    }
    
    /* Tables - fit to screen, hide columns */
    .table-wrapper {
        overflow-x: hidden;
    }
    
    .table {
        min-width: 0;
        width: 100%;
    }
    
    .table th,
    .table td {
        padding: 10px 8px;
        font-size: 13px;
    }
    
    /* Hide columns marked for mobile */
    .hide-mobile {
        display: none !important;
    }
    
    /* Modal - full width on mobile */
    .modal {
        width: 95%;
        max-height: 85vh;
    }
    
    /* Work items - full width tap targets */
    .work-item {
        padding: 16px;
    }
    
    .work-item .item-checkbox {
        width: 28px;
        height: 28px;
    }
    
    /* Buttons - larger tap targets */
    .btn {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    .btn-lg {
        min-height: 48px;
        padding: 14px 24px;
    }
    
    /* Form inputs - larger tap targets */
    .form-input,
    .form-select {
        min-height: 44px;
        padding: 10px 12px;
    }
    
    /* Stat cards - smaller on mobile */
    .stat-card {
        padding: 16px;
    }
    
    .stat-value {
        font-size: 28px;
    }
}
