/* --- Theme Variables --- */
:root {
    /* Light Theme */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --accent: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.7);

    --text-main: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
}

[data-theme='dark'] {
    /* Dark Theme */
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-glass: rgba(30, 41, 59, 0.7);

    --text-main: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --border: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.2);
}

/* --- Global Styles --- */
#ag-root {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    padding: 20px;
    box-sizing: border-box;
}

#ag-root * {
    box-sizing: border-box;
}

/* --- Layout --- */
.ag-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 90px;
}

/* Header */
.ag-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
}

.ag-logo {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Cards */
.ag-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.ag-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

/* Buttons */
.ag-btn {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.ag-btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.ag-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.ag-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.ag-btn-ghost:hover {
    background: var(--bg-surface);
    color: var(--primary);
    border-color: var(--primary);
}

.ag-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.ag-icon-btn:hover {
    background: var(--bg-body);
    color: var(--primary);
    transform: scale(1.05);
}

.ag-icon-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

/* Tabs */
.ag-tabs {
    display: flex;
    gap: 8px;
    background: var(--bg-surface);
    padding: 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.ag-tabs::-webkit-scrollbar {
    height: 4px;
}

.ag-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.ag-tabs::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.ag-tab {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s;
    border: none;
    background: transparent;
    white-space: nowrap;
    flex-shrink: 0;
}

.ag-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Search */
.ag-search {
    width: 100%;
    max-width: 400px;
    padding: 12px 16px;
    padding-left: 45px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-main);
    outline: none;
    transition: all 0.2s;
}

.ag-search:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Task List */
.ag-task-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-body);
    margin-bottom: 8px;
    transition: all 0.2s;
    border: 1px solid transparent;
    overflow-x: hidden;
}

.ag-task-item:hover {
    border-color: var(--border);
    transform: translateX(4px);
}

.ag-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--text-muted);
    cursor: pointer;
    appearance: none;
    position: relative;
    transition: all 0.2s;
    margin-right: 12px;
    flex-shrink: 0;
}

.ag-checkbox:checked {
    background: var(--success);
    border-color: var(--success);
}

.ag-checkbox:checked::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 12px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Focus Timer Overlay */
.ag-timer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    animation: fadeIn 0.3s ease;
    padding: 16px;
    text-align: center;
}

.ag-timer-ring {
    width: min(300px, 80vw);
    height: min(300px, 80vw);
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 72px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    position: relative;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.2) 0%, transparent 70%);
    box-shadow: 0 0 60px rgba(99, 102, 241, 0.3);
    margin-bottom: 32px;
}

/* Fullscreen timer */
.ag-timer-overlay.fullscreen {
    background: #000000;
}

.ag-timer-overlay.fullscreen .ag-timer-ring {
    width: min(400px, 90vw);
    height: min(400px, 90vw);
    font-size: 96px;
}

/* Quick Add Task */
.ag-quick-add {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    align-items: center;
}

.ag-quick-add input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-main);
    outline: none;
    font-size: 14px;
    height: 36px;
}

.ag-quick-add input:focus {
    border-color: var(--primary);
}

.ag-quick-add .ant-select {
    flex: 0 0 90px;
}

.ag-quick-add .ant-select-selector {
    height: 36px !important;
    align-items: center;
    display: flex;
}

.ag-quick-add .ag-icon-btn {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
}

/* Custom Select Dropdown Styling */
.ant-select {
    font-family: 'Plus Jakarta Sans', sans-serif !important;
}

.ant-select-selector {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    color: var(--text-main) !important;
    transition: all 0.2s ease !important;
}

.ant-select-selector:hover {
    border-color: var(--primary) !important;
}

.ant-select-focused .ant-select-selector {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1) !important;
}

.ant-select-arrow {
    color: var(--text-secondary) !important;
}

.ant-select-selection-item {
    color: var(--text-main) !important;
}

.ant-select-selection-placeholder {
    color: var(--text-muted) !important;
}

/* Dropdown menu styling */
.ant-select-dropdown {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 4px !important;
}

.ant-select-item {
    color: var(--text-main) !important;
    border-radius: var(--radius-sm) !important;
    margin: 2px 0 !important;
}

.ant-select-item-option-active:not(.ant-select-item-option-disabled) {
    background: rgba(99, 102, 241, 0.08) !important;
}

.ant-select-item-option-selected:not(.ant-select-item-option-disabled) {
    background: rgba(99, 102, 241, 0.15) !important;
    color: var(--primary) !important;
    font-weight: 600 !important;
}

/* Dark mode specific adjustments */
[data-theme='dark'] .ant-select-selector {
    background: var(--bg-surface) !important;
}

[data-theme='dark'] .ant-select-dropdown {
    background: var(--bg-surface) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
}

[data-theme='dark'] .ant-select-item-option-active:not(.ant-select-item-option-disabled) {
    background: rgba(99, 102, 241, 0.2) !important;
}

[data-theme='dark'] .ant-select-item-option-selected:not(.ant-select-item-option-disabled) {
    background: rgba(99, 102, 241, 0.25) !important;
}

/* XP History Styles */
.xp-history-item {
    padding: 16px;
    border-radius: var(--radius-md);
    background: var(--bg-body);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.xp-history-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.xp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 14px;
}

.xp-badge.positive {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.xp-badge.negative {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

/* Mobile */
@media (max-width: 768px) {
    #ag-root {
        padding: 16px;
    }

    .ag-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .ag-controls {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .ag-card {
        padding: 18px;
        border-radius: var(--radius-md);
    }

    .ag-tabs {
        width: 100%;
        justify-content: flex-start;
    }

    .ag-tab {
        padding: 8px 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .ag-task-item {
        padding: 10px;
    }
}

.ag-quick-add .ag-icon-btn {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
}

/* Custom Select Dropdown Styling */
.ant-select {
    font-family: 'Plus Jakarta Sans', sans-serif !important;
}

.ant-select-selector {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    color: var(--text-main) !important;
    transition: all 0.2s ease !important;
}

.ant-select-selector:hover {
    border-color: var(--primary) !important;
}

.ant-select-focused .ant-select-selector {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1) !important;
}

.ant-select-arrow {
    color: var(--text-secondary) !important;
}

.ant-select-selection-item {
    color: var(--text-main) !important;
}

.ant-select-selection-placeholder {
    color: var(--text-muted) !important;
}

/* Dropdown menu styling */
.ant-select-dropdown {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 4px !important;
}

.ant-select-item {
    color: var(--text-main) !important;
    border-radius: var(--radius-sm) !important;
    margin: 2px 0 !important;
}

.ant-select-item-option-active:not(.ant-select-item-option-disabled) {
    background: rgba(99, 102, 241, 0.08) !important;
}

.ant-select-item-option-selected:not(.ant-select-item-option-disabled) {
    background: rgba(99, 102, 241, 0.15) !important;
    color: var(--primary) !important;
    font-weight: 600 !important;
}

/* Dark mode specific adjustments */
[data-theme='dark'] .ant-select-selector {
    background: var(--bg-surface) !important;
}

[data-theme='dark'] .ant-select-dropdown {
    background: var(--bg-surface) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
}

[data-theme='dark'] .ant-select-item-option-active:not(.ant-select-item-option-disabled) {
    background: rgba(99, 102, 241, 0.2) !important;
}

[data-theme='dark'] .ant-select-item-option-selected:not(.ant-select-item-option-disabled) {
    background: rgba(99, 102, 241, 0.25) !important;
}

/* XP History Styles */
.xp-history-item {
    padding: 16px;
    border-radius: var(--radius-md);
    background: var(--bg-body);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.xp-history-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.xp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 14px;
}

.xp-badge.positive {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.xp-badge.negative {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

/* Mobile */
@media (max-width: 768px) {
    #ag-root {
        padding: 16px;
    }

    .ag-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .ag-controls {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .ag-card {
        padding: 18px;
        border-radius: var(--radius-md);
    }

    .ag-tabs {
        width: 100%;
        justify-content: flex-start;
    }

    .ag-tab {
        padding: 8px 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .ag-task-item {
        padding: 10px;
    }

    .ag-logo {
        font-size: 20px;
    }

    .ag-tab {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Ant Design Dark Mode Overrides */
[data-theme='dark'] .ant-modal-content {
    background: var(--bg-surface) !important;
    color: var(--text-main) !important;
}

[data-theme='dark'] .ant-modal-header {
    background: var(--bg-surface) !important;
    border-bottom-color: var(--border) !important;
}

[data-theme='dark'] .ant-modal-title {
    color: var(--text-main) !important;
}

[data-theme='dark'] .ant-modal-close {
    color: var(--text-secondary) !important;
}

[data-theme='dark'] .ant-modal-close:hover {
    color: var(--text-main) !important;
}

[data-theme='dark'] .ant-modal-footer {
    background: var(--bg-surface) !important;
    border-top-color: var(--border) !important;
}

[data-theme='dark'] .ant-drawer-content {
    background: var(--bg-surface) !important;
    color: var(--text-main) !important;
}

[data-theme='dark'] .ant-drawer-header {
    background: var(--bg-surface) !important;
    border-bottom-color: var(--border) !important;
    color: var(--text-main) !important;
}

[data-theme='dark'] .ant-drawer-title {
    color: var(--text-main) !important;
}

[data-theme='dark'] .ant-drawer-close {
    color: var(--text-secondary) !important;
}

[data-theme='dark'] .ant-drawer-body {
    background: var(--bg-surface) !important;
}

/* Input fields in dark mode */
[data-theme='dark'] input[type="text"],
[data-theme='dark'] input[type="date"],
[data-theme='dark'] input[type="number"],
[data-theme='dark'] textarea {
    background: var(--bg-body) !important;
    border-color: var(--border) !important;
    color: var(--text-main) !important;
}

[data-theme='dark'] input::placeholder,
[data-theme='dark'] textarea::placeholder {
    color: var(--text-muted) !important;
}

/* Color input in dark mode */
[data-theme='dark'] input[type="color"] {
    background: var(--bg-body) !important;
    border-color: var(--border) !important;
}

/* Labels in dark mode */
[data-theme='dark'] label {
    color: var(--text-secondary) !important;
}