/* Invoice-a-rama Styles */

:root {
    --color-bg: #f5f5f7;
    --color-surface: #ffffff;
    --color-primary: #1d4ed8;
    --color-primary-light: #3b82f6;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

/* Header */
.app-header {
    background: var(--color-surface);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-primary);
    line-height: 1.2;
}

.app-header .subtitle {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.header-status {
    text-align: right;
}

.status-date {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 0.25rem;
}

.status-count {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    background: var(--color-surface);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    display: inline-block;
}

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

/* App Controls (Tabs & Sort) */
.app-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

/* PM Tabs */
.pm-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex: 1;
}

.pm-tab {
    padding: 0.5rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    white-space: nowrap;
}

.pm-tab:hover {
    border-color: var(--color-primary-light);
    color: var(--color-primary);
}

.pm-tab.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* Sort Controls */
.sort-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.sort-controls label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.sort-controls select {
    padding: 0.5rem 2rem 0.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    font-size: 0.875rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%236b7280%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem top 50%;
    background-size: 0.65rem auto;
}

/* Status bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

/* Time entries container */
.time-entries {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Project card */
.project-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.project-header:hover {
    background: var(--color-bg);
}

.project-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.project-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-name {
    font-weight: 600;
    font-size: 1rem;
}

.client-name {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-left: 1.5rem;
    /* Indent to align with text, past icon */
}

.project-hours {
    font-weight: 600;
    color: var(--color-primary);
    white-space: nowrap;
}

.toggle-icon {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    transition: transform 0.2s;
    width: 1rem;
    text-align: center;
}

.project-card.expanded .toggle-icon {
    transform: rotate(90deg);
}

.project-content {
    display: none;
    border-top: 1px solid var(--color-border);
}

.project-card.expanded .project-content {
    display: block;
}

/* No time tracked projects */
.project-card.no-time-project {
    opacity: 0.7;
    background: #f9fafb;
}

.project-card.no-time-project .project-name,
.project-card.no-time-project .client-name {
    color: var(--color-text-muted);
}

.no-time-message {
    display: flex;
    align-items: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    padding-right: 1rem;
}

.no-time-message em {
    font-style: italic;
}

/* Person section */
.person-section {
    border-bottom: 1px solid var(--color-border);
}

.person-section:last-child {
    border-bottom: none;
}

.person-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    padding-left: 2rem;
    cursor: pointer;
    background: #fafafa;
    transition: background 0.15s;
}

.person-header:hover {
    background: #f0f0f0;
}

.person-name {
    font-weight: 500;
    font-size: 0.9375rem;
}

.person-hours {
    font-weight: 500;
    color: var(--color-text-muted);
}

.person-entries {
    display: none;
}

.person-section.expanded .person-entries {
    display: block;
}

/* Time entry */
.time-entry {
    display: grid;
    grid-template-columns: 100px 60px 1fr;
    gap: 1rem;
    padding: 0.625rem 1.25rem;
    padding-left: 3rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.875rem;
}

.entry-date {
    color: var(--color-text-muted);
}

.entry-hours {
    font-weight: 500;
}

.entry-notes {
    color: var(--color-text);
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--color-text-muted);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

/* Error state */
.error-state {
    text-align: center;
    padding: 2rem;
    background: #fef2f2;
    color: #991b1b;
    border-radius: var(--radius);
    border: 1px solid #fecaca;
}

/* Actual hours (secondary display) */
.actual-hours {
    font-size: 0.85em;
    color: var(--color-text-muted);
    font-weight: normal;
    margin-left: 4px;
}
/* Harvest Link */
.harvest-link {
    display: inline-flex;
    align-items: center;
    color: var(--color-text-muted);
    transition: all 0.15s;
    opacity: 0.5;
    margin-left: 0.25rem;
}

.harvest-link:hover {
    color: var(--color-primary);
    opacity: 1;
    transform: translateY(-1px);
}

/* Buttons */
.btn-secondary {
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.875rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: var(--color-primary-light);
    color: var(--color-primary);
}

.btn-secondary .icon {
    font-size: 1.1em;
}

/* Syncing button state */
.btn-secondary.syncing {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

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

/* Login Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none; /* Managed by JS */
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

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

.modal {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    font-size: 1rem;
}

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

.btn-text {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 0.875rem;
    text-decoration: underline;
}

.error-message {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 1rem;
    text-align: center;
    min-height: 1.25em;
}

/* Hours Group (three-value display in project header) */
.hours-group {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    white-space: nowrap;
}

.hours-group label {
    display: block;
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
    line-height: 1;
}

.hours-value {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.hours-value strong {
    color: var(--color-primary);
    font-size: 1rem;
    font-weight: 600;
}

.hours-value .actual-hours {
    font-size: 1rem;
    font-weight: 600;
}

.hours-input-wrapper {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.hours-input {
    width: 80px;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-primary);
    text-align: right;
    background: #ecfdf5;
}

.hours-input.has-value {
    background: #f0f7ff;
}

.hours-input:focus {
    outline: none;
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.hours-input::placeholder {
    color: #d1d5db;
    font-weight: 600;
}

/* Hide number input spinners */
.hours-input::-webkit-outer-spin-button,
.hours-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.hours-input[type=number] {
    -moz-appearance: textfield;
}

/* Invoice Fields (expanded card section) */
.invoice-fields {
    padding: 1rem 1.25rem;
    background: #fafafa;
    border-bottom: 1px solid var(--color-border);
}

/* Shared styles for all form elements in invoice fields */
.invoice-fields input:not([type="checkbox"]),
.invoice-fields select,
.invoice-fields textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
}

.invoice-fields input:not([type="checkbox"]):focus,
.invoice-fields select:focus,
.invoice-fields textarea:focus {
    outline: none;
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.invoice-field-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.invoice-field-row:last-child {
    margin-bottom: 0;
}

.invoice-field {
    flex: 1;
}

.invoice-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

/* Notes Textarea */
.notes-textarea {
    width: 100%;
    resize: vertical;
    min-height: 3.75rem;
    background: var(--color-surface);
    color: var(--color-text);
}

.notes-textarea::placeholder {
    color: var(--color-text-muted);
}

/* Status Select (dropdown in project header) */
.status-select {
    padding: 0.2rem 1.5rem 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid;
    appearance: none;
    -webkit-appearance: none;
    text-align: center;
    min-width: 120px;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%236b7280%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 0.5rem auto;
}

.status-select.status-ready_for_review {
    background-color: #fffbeb;
    color: #92400e;
    border-color: #fcd34d;
}

.status-select.status-reviewed {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #93c5fd;
}

.status-select.status-invoiced {
    background-color: #ecfdf5;
    color: #065f46;
    border-color: #6ee7b7;
}

/* PM Select (reassignment dropdown) */
.pm-select {
    width: 100%;
    background: var(--color-surface);
    cursor: pointer;
    color: var(--color-text);
}

/* Invoice Hours Input (in expanded section) */
.invoice-hours-input {
    width: 100%;
    font-weight: 600;
    color: var(--color-primary);
    text-align: right;
    background: #ecfdf5;
}

.invoice-hours-input.has-value {
    background: #f0f7ff;
}

.invoice-hours-input::placeholder {
    color: #d1d5db;
    font-weight: 600;
}

.invoice-hours-input::-webkit-outer-spin-button,
.invoice-hours-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.invoice-hours-input[type=number] {
    -moz-appearance: textfield;
}

/* Ready to Invoice Checkbox */
.ready-checkbox {
    width: 34px;
    height: 34px;
    cursor: pointer;
    margin-top: 0;
}

/* PM Tab States */
.pm-tab.empty {
    opacity: 0.5;
    font-style: italic;
}

.pm-tab-unassigned {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.pm-tab-unassigned:hover {
    border-color: #f87171;
    color: #991b1b;
}

.pm-tab-unassigned.active {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}
