/* PA Agent — Mobile-first PWA Styles */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-card-done: #0d1520;
    --accent: #4f8cff;
    --accent-glow: rgba(79, 140, 255, 0.15);
    --success: #00d68f;
    --danger: #ff6b6b;
    --text-primary: #e8e8ef;
    --text-secondary: #8888a0;
    --text-muted: #555570;
    --border: #2a2a45;
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.screen {
    min-height: 100vh;
    min-height: 100dvh;
}

/* === Login Screen === */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 2rem;
}

.logo {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.login-container h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 400px;
}

.input-group input {
    flex: 1;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--accent);
}

.input-group button, #complete-btn {
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius);
    border: none;
    background: var(--accent);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    white-space: nowrap;
}

.input-group button:active, #complete-btn:active {
    transform: scale(0.97);
}

.error-text {
    color: var(--danger);
    margin-top: 1rem;
    font-size: 0.875rem;
}

/* === Main Screen === */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 0.25rem;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--accent-glow);
}

/* Date bar */
.date-bar {
    text-align: center;
    padding: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

/* Progress bar */
.progress-container {
    position: relative;
    height: 32px;
    background: var(--bg-secondary);
    margin: 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    transition: width 0.5s ease;
    width: 0%;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Items */
.items-container {
    padding: 1rem;
    padding-bottom: 100px;
}

.loading, .empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.items-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.item-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.item-card:active {
    transform: scale(0.98);
}

.item-card.completed {
    background: var(--bg-card-done);
    opacity: 0.5;
    border-color: transparent;
}

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

.item-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.item-card.completed .item-number {
    background: rgba(0, 214, 143, 0.15);
    color: var(--success);
}

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

.item-tag {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.35rem;
}

.tag-CALL { background: rgba(255,107,107,0.15); color: #ff6b6b; }
.tag-EMAIL { background: rgba(79,140,255,0.15); color: #4f8cff; }
.tag-TELEGRAM { background: rgba(0,136,204,0.15); color: #0088cc; }
.tag-SMS { background: rgba(160,120,255,0.15); color: #a078ff; }
.tag-CLICKUP { background: rgba(255,170,50,0.15); color: #ffaa32; }

.item-content {
    font-size: 0.9375rem;
    line-height: 1.4;
    color: var(--text-primary);
}

.item-sender {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Bottom bar */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    z-index: 10;
}

.completion-input {
    display: flex;
    gap: 0.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.completion-input input {
    flex: 1;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.completion-input input:focus {
    border-color: var(--accent);
}

/* Responsive */
@media (min-width: 768px) {
    .items-container {
        max-width: 700px;
        margin: 0 auto;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.item-card {
    animation: fadeIn 0.3s ease backwards;
}

.items-list .item-card:nth-child(1) { animation-delay: 0.05s; }
.items-list .item-card:nth-child(2) { animation-delay: 0.1s; }
.items-list .item-card:nth-child(3) { animation-delay: 0.15s; }
.items-list .item-card:nth-child(4) { animation-delay: 0.2s; }
.items-list .item-card:nth-child(5) { animation-delay: 0.25s; }
.items-list .item-card:nth-child(6) { animation-delay: 0.3s; }
.items-list .item-card:nth-child(7) { animation-delay: 0.35s; }
.items-list .item-card:nth-child(8) { animation-delay: 0.4s; }
.items-list .item-card:nth-child(9) { animation-delay: 0.45s; }
.items-list .item-card:nth-child(10) { animation-delay: 0.5s; }

/* Pull to refresh indicator */
.syncing {
    text-align: center;
    padding: 0.5rem;
    color: var(--accent);
    font-size: 0.875rem;
}

.toolbar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.toolbar select,
.small-btn,
.action-btn,
.modal-card textarea {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.toolbar select {
    flex: 1;
    padding: 0.65rem 0.8rem;
}

.small-btn {
    padding: 0.65rem 0.9rem;
    cursor: pointer;
}

.small-btn.wide {
    width: 100%;
    margin-top: 0.75rem;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.7rem;
}

.action-btn {
    padding: 0.38rem 0.55rem;
    font-size: 0.74rem;
    cursor: pointer;
}

.action-btn.success {
    border-color: rgba(0,214,143,0.35);
    color: var(--success);
}

.action-btn.danger {
    border-color: rgba(255,107,107,0.35);
    color: var(--danger);
}

.resolution-badge {
    display: inline-block;
    margin-left: 0.35rem;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.resolution-badge.completed { color: var(--success); }
.resolution-badge.dismissed { color: var(--danger); }
.resolution-badge.snoozed { color: #ffd166; }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 50;
}

.modal.hidden {
    display: none;
}

.modal-card {
    width: min(600px, 100%);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

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

.modal-card textarea {
    width: 100%;
    min-height: 180px;
    padding: 0.9rem;
}

.tab-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.35rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 0.7rem 0.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 600;
}

.tab-btn.active {
    color: var(--text-primary);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-glow);
}

.tab-panel {
    display: none;
    padding-bottom: 100px;
}

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

.section-card,
.history-card {
    margin: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.section-header,
.history-top,
.search-row {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    justify-content: space-between;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.9rem;
}

.kpi-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.kpi-value {
    font-size: 1.35rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

.list-stack {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 0.75rem;
}

.stack-item {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.8rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.search-row input,
.search-row select {
    flex: 1;
    padding: 0.75rem 0.85rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.history-meta,
.slot-badge {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
}

.slot-badge {
    display: inline-block;
    margin-left: 0.45rem;
}
