/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container and layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 0;
    margin-bottom: 24px;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header h1 {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Sections */
.section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

.section h2 {
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 16px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 8px;
}

.section h3 {
    color: #34495e;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 16px 0 8px 0;
}

.section h4 {
    color: #495057;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 12px 0 8px 0;
}

/* Form elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-group label {
    font-weight: 500;
    color: #495057;
    font-size: 0.95rem;
}

.input-group {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.input-group input[type="text"] {
    flex: 1;
    border-radius: 8px 0 0 8px;
}

.input-group .btn {
    border-radius: 0 8px 8px 0;
    min-width: 60px;
}

.input-group .btn.recording {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    animation: pulse 1.5s ease-in-out infinite;
}

.input-group .btn.recording:hover {
    background: linear-gradient(135deg, #c82333 0%, #a71e2a 100%);
}

.audio-visualizer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #e9ecef;
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: #dc3545;
}

.recording-dot {
    width: 12px;
    height: 12px;
    background: #dc3545;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

#recording-duration {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    background: #dc3545;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 45px;
    text-align: center;
}

.silence-indicator {
    color: #fffbe6;
    background: #ffc107;
    font-weight: bold;
    border-radius: 4px;
    padding: 2px 8px;
    margin-left: 10px;
    animation: blink 1s ease-in-out infinite;
    font-size: 0.95em;
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0.3;
    }
}

input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: #fff;
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input[type="text"]::placeholder {
    color: #adb5bd;
}

input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: #fff;
}

input[type="password"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    /* Touch target size */
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #c82333 0%, #a71e2a 100%);
}

/* Checkbox styling */
.checkbox-group {
    margin: 8px 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    color: #495057;
    gap: 8px;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

/* Messages */
.message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
    width: calc(100vw - 40px);
}

.message {
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

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

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

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

.message.info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* Todo result */
.todo-details {
    background-color: #f8f9fa;
    padding: 24px 24px 20px 24px;
    border-radius: 10px;
    border-left: 5px solid #28a745;
    box-shadow: 0 2px 12px rgba(40, 167, 69, 0.07), 0 1.5px 4px rgba(0, 0, 0, 0.04);
    margin-bottom: 8px;
}

.todo-details p {
    margin: 14px 0 10px 0;
    font-size: 1.12rem;
    color: #222;
    letter-spacing: 0.01em;
}

.todo-details strong {
    color: #222;
    font-weight: 700;
    font-size: 1.08em;
}

.todo-details span {
    color: #222;
    font-weight: 500;
    font-size: 1.08em;
    letter-spacing: 0.01em;
}

/* Memory sections */
.memory-section {
    margin-top: 16px;
}

.memory-group {
    margin-bottom: 24px;
}

.memory-category {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
    border: 1px solid #e9ecef;
}

.memory-category h5 {
    color: #495057;
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 1rem;
}

.memory-item {
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 16px;
    margin: 8px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.memory-item p {
    margin: 4px 0;
    font-size: 0.95rem;
}

.memory-item strong {
    color: #495057;
    font-weight: 600;
}

.memory-item .delete-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    margin-top: 8px;
    transition: background-color 0.2s ease;
}

.memory-item .delete-btn:hover {
    background: #c82333;
}

/* Usage examples */
.usage-examples {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.example-group {
    background-color: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.example-group ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.example-group li {
    margin: 6px 0;
    font-size: 0.95rem;
    color: #495057;
}

/* Danger section */
.danger-section {
    border: 2px solid #dc3545;
    background-color: #fff5f5;
}

.danger-content {
    text-align: center;
}

.danger-content p {
    color: #721c24;
    margin: 12px 0;
    font-weight: 500;
}

/* Success and error states */
.success {
    border-left: 4px solid #28a745;
    background-color: #f8fff9;
}

.error {
    border-left: 4px solid #dc3545;
    background-color: #fff5f5;
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 0 12px;
    }

    .header {
        padding: 16px 0;
        margin-bottom: 16px;
    }

    .header h1 {
        font-size: 1.75rem;
    }

    .section {
        padding: 16px;
        margin-bottom: 16px;
    }

    .section h2 {
        font-size: 1.25rem;
    }

    .section h3 {
        font-size: 1.1rem;
    }

    .btn {
        width: 100%;
        margin: 8px 0;
    }

    /* Keep input group buttons compact on mobile */
    .input-group .btn {
        width: auto;
        min-width: 48px;
        /* Increased for better touch target */
        margin: 0;
        padding: 12px;
        font-size: 1.1rem;
    }

    /* Better form spacing on mobile */
    .form-group {
        gap: 16px;
    }

    /* Mobile-friendly audio settings */
    .audio-settings>div {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .audio-settings label {
        min-width: auto !important;
        margin-bottom: 4px;
    }

    .audio-settings select,
    .audio-settings input[type="range"] {
        max-width: none !important;
        width: 100% !important;
    }

    .message-container {
        top: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
    }

    .message {
        font-size: 0.9rem;
        padding: 12px;
    }

    .todo-details {
        padding: 12px;
    }

    .memory-item {
        padding: 12px;
    }

    .example-group {
        padding: 12px;
    }

    .example-group li {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 8px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .section {
        padding: 12px;
    }

    .section h2 {
        font-size: 1.1rem;
    }

    input[type="text"] {
        padding: 12px 14px;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    .btn {
        padding: 12px 16px;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    /* Smaller microphone button for very small screens */
    .input-group .btn {
        min-width: 44px;
        padding: 12px 10px;
        font-size: 1rem;
    }

    /* Better input group layout on small screens */
    .input-group {
        gap: 6px;
    }

    .memory-item {
        padding: 10px;
    }

    .memory-item p {
        font-size: 0.9rem;
    }

    /* Improve audio visualizer layout on small screens */
    .audio-visualizer {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .recording-indicator {
        justify-content: center;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e9ecef;
    }

    .section {
        background-color: #232326;
        border-color: #35363a;
    }

    .section h2 {
        color: #e9ecef;
        border-bottom-color: #35363a;
        font-weight: 800;
    }

    .section h3 {
        color: #dee2e6;
    }

    .section h4 {
        color: #ced4da;
    }

    input[type="text"] {
        background-color: #232326;
        border-color: #444;
        color: #e9ecef;
    }

    input[type="text"]:focus {
        border-color: #667eea;
    }

    input[type="text"]::placeholder {
        color: #6c757d;
    }

    .memory-category {
        background-color: #28282c;
        border-color: #3a3b3f;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
        margin-bottom: 20px;
    }

    .memory-category h5 {
        color: #bfc7d5;
        font-weight: 700;
        letter-spacing: 0.5px;
        margin-bottom: 14px;
    }

    .memory-item {
        background-color: #232326;
        border-color: #35363a;
        color: #e9ecef;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
        margin-bottom: 12px;
    }

    .memory-item p {
        color: #cfd2da;
    }

    .memory-item strong {
        color: #f1f3f6;
    }

    .memory-item .delete-btn {
        background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
        color: #fff;
        border: none;
        margin-top: 10px;
        margin-left: 2px;
        margin-bottom: 2px;
        box-shadow: 0 2px 6px rgba(231, 76, 60, 0.12);
    }

    .memory-item .delete-btn:hover {
        background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    }

    .memory-group {
        margin-bottom: 28px;
    }

    .example-group {
        background-color: #23232a;
        border: 1.5px solid #35363a;
        border-radius: 10px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
        margin-bottom: 18px;
    }

    .example-group h3 {
        color: #bfc7d5;
        font-weight: 700;
        margin-bottom: 8px;
    }

    .example-group ul {
        color: #e9ecef;
    }

    .example-group li {
        color: #cfd2da;
        margin-bottom: 6px;
    }

    .checkbox-label {
        color: #e9ecef;
    }

    .form-group label {
        color: #e9ecef;
    }

    .btn-primary {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: #fff;
    }

    .btn-secondary {
        background: #444;
        color: #fff;
        border: 1.5px solid #35363a;
    }

    .btn-danger {
        background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
        color: #fff;
    }

    .btn-danger:hover {
        background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    }

    .todo-details {
        background-color: #232326;
        border-left: 5px solid #28a745;
        box-shadow: 0 2px 12px rgba(40, 167, 69, 0.13), 0 1.5px 4px rgba(0, 0, 0, 0.18);
    }

    .todo-details p,
    .todo-details strong,
    .todo-details span {
        color: #f1f3f6;
    }
}

/* Todoist Integration */
.todoist-status {
    margin-bottom: 16px;
}

.todoist-status p {
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 6px;
    background-color: #f8f9fa;
    border-left: 4px solid #6c757d;
    color: #333;
}

.todoist-setup {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.todoist-setup h3 {
    color: #856404;
    margin-top: 0;
}

.todoist-setup p {
    color: #856404;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.todoist-connected {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.todoist-connected h3 {
    color: #155724;
    margin-top: 0;
}

.todoist-connected p {
    color: #155724;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

@media (prefers-color-scheme: dark) {
    .todoist-status p {
        background-color: #232326;
        border-left: 4px solid #888;
        color: #e9ecef;
    }

    .todoist-setup {
        background-color: #3a3626;
        border: 1px solid #bfae6a;
    }

    .todoist-setup h3,
    .todoist-setup p {
        color: #ffeaa7;
    }

    .todoist-connected {
        background-color: #233326;
        border: 1px solid #3fae6a;
    }

    .todoist-connected h3,
    .todoist-connected p {
        color: #b6f7c6;
    }
}

.audio-settings {
    margin-top: 8px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.audio-settings small {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6c757d;
}

.audio-settings label {
    font-weight: 500;
    margin: 0;
}

.audio-settings select {
    padding: 2px 6px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: white;
    font-size: 0.875rem;
}

.audio-settings-section {
    margin-top: 24px;
}

/* Project Assignment Styles */
.project-assignment {
    background: #e8f5e8;
    border: 1px solid #4caf50;
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
}

.project-assignment strong {
    color: #2e7d32;
}

.project-assignment small {
    color: #666;
    font-style: italic;
}

.project-rules-status {
    margin-bottom: 16px;
}

.project-rules-status p {
    color: #666;
    font-style: italic;
}

.project-rules-setup {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.project-rules-setup h3 {
    color: #856404;
    margin-bottom: 8px;
}

.project-rules-setup p {
    color: #856404;
    margin: 0;
}

.project-rules-manager {
    margin-bottom: 16px;
}

.project-rules-list {
    margin: 16px 0;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.project-rule {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.project-rule:last-child {
    margin-bottom: 0;
}

.project-rule h5 {
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.project-rule p {
    margin: 4px 0;
    color: #666;
}

.project-rule strong {
    color: #495057;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
    margin-top: 8px;
}

select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    background-color: white;
    color: #333;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Dark mode support for project assignment */
@media (prefers-color-scheme: dark) {
    .project-assignment {
        background: #1e3a1e;
        border-color: #4caf50;
    }

    .project-assignment strong {
        color: #81c784;
    }

    .project-assignment small {
        color: #aaa;
    }

    .project-rules-setup {
        background: #3d2c1e;
        border-color: #ffb74d;
    }

    .project-rules-setup h3,
    .project-rules-setup p {
        color: #ffb74d;
    }

    .project-rules-list {
        background: #2d3748;
        border-color: #4a5568;
    }

    .project-rule {
        background: #1a202c;
        border-color: #4a5568;
    }

    .project-rule h5 {
        color: #e2e8f0;
    }

    .project-rule p {
        color: #a0aec0;
    }

    .project-rule strong {
        color: #cbd5e0;
    }

    select {
        background-color: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    select:focus {
        border-color: #667eea;
    }
}

/* Settings Section Styles */
.settings-section {
    margin-top: 24px;
}

.settings-header {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.settings-header:hover {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 8px;
    margin: -8px;
}

.settings-header h2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

#settings-toggle {
    font-size: 0.8em;
    transition: transform 0.3s ease;
}

.settings-content {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid #e9ecef;
}

.settings-group {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e9ecef;
}

.settings-group:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.settings-group h3 {
    color: #495057;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

/* Dark mode support for settings */
@media (prefers-color-scheme: dark) {
    .settings-header:hover {
        background-color: #2c3e50;
    }

    .settings-content {
        border-top-color: #495057;
    }

    .settings-group {
        border-bottom-color: #495057;
    }

    .settings-group h3 {
        color: #adb5bd;
    }
}

@media (prefers-color-scheme: dark) {
    .audio-settings {
        background: #232326 !important;
        border: 1px solid #35363a !important;
    }

    .audio-settings label,
    .audio-settings #silence-threshold-value {
        color: #e9ecef !important;
    }

    .audio-settings select {
        background: #232326 !important;
        color: #e9ecef !important;
        border: 1px solid #444 !important;
    }

    .audio-settings input[type="range"] {
        background: #35363a !important;
    }

    .audio-settings small {
        color: #adb5bd !important;
    }
}