sigye 0.4.1

A beautiful terminal clock with ASCII art fonts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
//! Settings dialog widget for configuring the clock.

use ratatui::{
    Frame,
    layout::{Alignment, Constraint, Layout, Rect},
    style::{Color, Style},
    text::{Line, Span},
    widgets::{Block, Borders, Clear, Paragraph},
};
use sigye_core::{AnimationSpeed, AnimationStyle, BackgroundStyle, ColorTheme, TimeFormat};

/// The settings field currently being edited.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum SettingsField {
    #[default]
    Font,
    Color,
    TimeFormat,
    ShowSeconds,
    Animation,
    Speed,
    Background,
    ColonBlink,
    PomodoroWork,
    PomodoroBreak,
    PomodoroLongBreak,
    PomodoroSound,
    DesktopNotifications,
    TimerDuration,
}

impl SettingsField {
    /// Move to the next field.
    pub fn next(self) -> Self {
        match self {
            Self::Font => Self::Color,
            Self::Color => Self::TimeFormat,
            Self::TimeFormat => Self::ShowSeconds,
            Self::ShowSeconds => Self::Animation,
            Self::Animation => Self::Speed,
            Self::Speed => Self::Background,
            Self::Background => Self::ColonBlink,
            Self::ColonBlink => Self::PomodoroWork,
            Self::PomodoroWork => Self::PomodoroBreak,
            Self::PomodoroBreak => Self::PomodoroLongBreak,
            Self::PomodoroLongBreak => Self::PomodoroSound,
            Self::PomodoroSound => Self::DesktopNotifications,
            Self::DesktopNotifications => Self::TimerDuration,
            Self::TimerDuration => Self::Font,
        }
    }

    /// Move to the previous field.
    pub fn prev(self) -> Self {
        match self {
            Self::Font => Self::TimerDuration,
            Self::TimerDuration => Self::DesktopNotifications,
            Self::DesktopNotifications => Self::PomodoroSound,
            Self::PomodoroSound => Self::PomodoroLongBreak,
            Self::Color => Self::Font,
            Self::TimeFormat => Self::Color,
            Self::ShowSeconds => Self::TimeFormat,
            Self::Animation => Self::ShowSeconds,
            Self::Speed => Self::Animation,
            Self::Background => Self::Speed,
            Self::ColonBlink => Self::Background,
            Self::PomodoroWork => Self::ColonBlink,
            Self::PomodoroBreak => Self::PomodoroWork,
            Self::PomodoroLongBreak => Self::PomodoroBreak,
        }
    }
}

/// A row in the settings dialog layout.
enum RowKind {
    Header(&'static str),
    Field(SettingsField),
    Spacer,
}

/// Settings dialog state.
#[derive(Debug)]
pub struct SettingsDialog {
    /// Whether the dialog is visible.
    pub visible: bool,
    /// Currently selected field.
    pub selected_field: SettingsField,
    /// Scroll offset for vertical scrolling.
    scroll_offset: u16,
    /// Index into available fonts list.
    pub font_index: usize,
    /// List of available font names.
    pub available_fonts: Vec<String>,
    /// Current color theme selection.
    pub color_theme: ColorTheme,
    /// Current time format selection.
    pub time_format: TimeFormat,
    /// Current animation style selection.
    pub animation_style: AnimationStyle,
    /// Current animation speed selection.
    pub animation_speed: AnimationSpeed,
    /// Current background style selection.
    pub background_style: BackgroundStyle,
    /// Current colon blink setting.
    pub colon_blink: bool,
    /// Current show seconds setting.
    pub show_seconds: bool,
    /// Pomodoro work duration in minutes.
    pub pomodoro_work_mins: u32,
    /// Pomodoro break duration in minutes.
    pub pomodoro_break_mins: u32,
    /// Pomodoro long break duration in minutes.
    pub pomodoro_long_break_mins: u32,
    /// Pomodoro sound notification setting.
    pub pomodoro_sound: bool,
    /// Desktop notifications setting.
    pub desktop_notifications: bool,
    /// Timer countdown duration in minutes.
    pub timer_duration_mins: u32,
    /// Original font index (for cancel/revert).
    original_font_index: usize,
    /// Original color theme (for cancel/revert).
    original_color_theme: ColorTheme,
    /// Original time format (for cancel/revert).
    original_time_format: TimeFormat,
    /// Original animation style (for cancel/revert).
    original_animation_style: AnimationStyle,
    /// Original animation speed (for cancel/revert).
    original_animation_speed: AnimationSpeed,
    /// Original background style (for cancel/revert).
    original_background_style: BackgroundStyle,
    /// Original colon blink (for cancel/revert).
    original_colon_blink: bool,
    /// Original show seconds (for cancel/revert).
    original_show_seconds: bool,
    /// Original pomodoro work duration (for cancel/revert).
    original_pomodoro_work_mins: u32,
    /// Original pomodoro break duration (for cancel/revert).
    original_pomodoro_break_mins: u32,
    /// Original pomodoro long break duration (for cancel/revert).
    original_pomodoro_long_break_mins: u32,
    /// Original pomodoro sound (for cancel/revert).
    original_pomodoro_sound: bool,
    /// Original desktop notifications (for cancel/revert).
    original_desktop_notifications: bool,
    /// Original timer duration (for cancel/revert).
    original_timer_duration_mins: u32,
}

impl SettingsDialog {
    /// Create a new settings dialog.
    pub fn new(available_fonts: Vec<String>) -> Self {
        Self {
            visible: false,
            selected_field: SettingsField::default(),
            scroll_offset: 0,
            font_index: 0,
            available_fonts,
            color_theme: ColorTheme::default(),
            time_format: TimeFormat::default(),
            animation_style: AnimationStyle::default(),
            animation_speed: AnimationSpeed::default(),
            background_style: BackgroundStyle::default(),
            colon_blink: false,
            show_seconds: true,
            pomodoro_work_mins: 25,
            pomodoro_break_mins: 5,
            pomodoro_long_break_mins: 15,
            pomodoro_sound: true,
            desktop_notifications: true,
            timer_duration_mins: 5,
            original_font_index: 0,
            original_color_theme: ColorTheme::default(),
            original_time_format: TimeFormat::default(),
            original_animation_style: AnimationStyle::default(),
            original_animation_speed: AnimationSpeed::default(),
            original_background_style: BackgroundStyle::default(),
            original_colon_blink: false,
            original_show_seconds: true,
            original_pomodoro_work_mins: 25,
            original_pomodoro_break_mins: 5,
            original_pomodoro_long_break_mins: 15,
            original_pomodoro_sound: true,
            original_desktop_notifications: true,
            original_timer_duration_mins: 5,
        }
    }

    /// Open dialog with current settings.
    #[allow(clippy::too_many_arguments)]
    pub fn open(
        &mut self,
        font_name: &str,
        color_theme: ColorTheme,
        time_format: TimeFormat,
        animation_style: AnimationStyle,
        animation_speed: AnimationSpeed,
        colon_blink: bool,
        show_seconds: bool,
        background_style: BackgroundStyle,
        pomodoro_work_mins: u32,
        pomodoro_break_mins: u32,
        pomodoro_long_break_mins: u32,
        pomodoro_sound: bool,
        desktop_notifications: bool,
        timer_duration_mins: u32,
    ) {
        self.visible = true;
        self.selected_field = SettingsField::default();
        self.scroll_offset = 0;
        self.color_theme = color_theme;
        self.time_format = time_format;
        self.animation_style = animation_style;
        self.animation_speed = animation_speed;
        self.background_style = background_style;
        self.colon_blink = colon_blink;
        self.show_seconds = show_seconds;
        self.pomodoro_work_mins = pomodoro_work_mins;
        self.pomodoro_break_mins = pomodoro_break_mins;
        self.pomodoro_long_break_mins = pomodoro_long_break_mins;
        self.pomodoro_sound = pomodoro_sound;
        self.desktop_notifications = desktop_notifications;
        self.timer_duration_mins = timer_duration_mins;

        // Find font index
        self.font_index = self
            .available_fonts
            .iter()
            .position(|f| f == font_name)
            .unwrap_or(0);

        // Store original values for cancel/revert
        self.original_font_index = self.font_index;
        self.original_color_theme = color_theme;
        self.original_time_format = time_format;
        self.original_animation_style = animation_style;
        self.original_animation_speed = animation_speed;
        self.original_background_style = background_style;
        self.original_colon_blink = colon_blink;
        self.original_show_seconds = show_seconds;
        self.original_pomodoro_work_mins = pomodoro_work_mins;
        self.original_pomodoro_break_mins = pomodoro_break_mins;
        self.original_pomodoro_long_break_mins = pomodoro_long_break_mins;
        self.original_pomodoro_sound = pomodoro_sound;
        self.original_desktop_notifications = desktop_notifications;
        self.original_timer_duration_mins = timer_duration_mins;
    }

    /// Close without saving.
    pub fn close(&mut self) {
        self.visible = false;
    }

    /// Get original font name (for reverting on cancel).
    pub fn original_font(&self) -> &str {
        self.available_fonts
            .get(self.original_font_index)
            .map(String::as_str)
            .unwrap_or("Standard")
    }

    /// Get original color theme (for reverting on cancel).
    pub fn original_color_theme(&self) -> ColorTheme {
        self.original_color_theme
    }

    /// Get original time format (for reverting on cancel).
    pub fn original_time_format(&self) -> TimeFormat {
        self.original_time_format
    }

    /// Get original animation style (for reverting on cancel).
    pub fn original_animation_style(&self) -> AnimationStyle {
        self.original_animation_style
    }

    /// Get original animation speed (for reverting on cancel).
    pub fn original_animation_speed(&self) -> AnimationSpeed {
        self.original_animation_speed
    }

    /// Get original colon blink (for reverting on cancel).
    pub fn original_colon_blink(&self) -> bool {
        self.original_colon_blink
    }

    /// Get original show seconds (for reverting on cancel).
    pub fn original_show_seconds(&self) -> bool {
        self.original_show_seconds
    }

    /// Get original background style (for reverting on cancel).
    pub fn original_background_style(&self) -> BackgroundStyle {
        self.original_background_style
    }

    /// Get original pomodoro work duration (for reverting on cancel).
    pub fn original_pomodoro_work_mins(&self) -> u32 {
        self.original_pomodoro_work_mins
    }

    /// Get original pomodoro break duration (for reverting on cancel).
    pub fn original_pomodoro_break_mins(&self) -> u32 {
        self.original_pomodoro_break_mins
    }

    /// Get original pomodoro long break duration (for reverting on cancel).
    pub fn original_pomodoro_long_break_mins(&self) -> u32 {
        self.original_pomodoro_long_break_mins
    }

    /// Get original pomodoro sound (for reverting on cancel).
    pub fn original_pomodoro_sound(&self) -> bool {
        self.original_pomodoro_sound
    }

    /// Get original desktop notifications (for reverting on cancel).
    pub fn original_desktop_notifications(&self) -> bool {
        self.original_desktop_notifications
    }

    /// Get original timer duration (for reverting on cancel).
    pub fn original_timer_duration_mins(&self) -> u32 {
        self.original_timer_duration_mins
    }

    /// Move to next field and ensure it's visible.
    pub fn next_field(&mut self) {
        self.selected_field = self.selected_field.next();
    }

    /// Move to previous field and ensure it's visible.
    pub fn prev_field(&mut self) {
        self.selected_field = self.selected_field.prev();
    }

    /// Get the section layout: ordered list of rows (headers, fields, spacers).
    fn section_layout() -> Vec<RowKind> {
        vec![
            RowKind::Header("Clock"),
            RowKind::Field(SettingsField::Font),
            RowKind::Field(SettingsField::Color),
            RowKind::Field(SettingsField::TimeFormat),
            RowKind::Field(SettingsField::ShowSeconds),
            RowKind::Field(SettingsField::ColonBlink),
            RowKind::Spacer,
            RowKind::Header("Animation"),
            RowKind::Field(SettingsField::Animation),
            RowKind::Field(SettingsField::Speed),
            RowKind::Field(SettingsField::Background),
            RowKind::Spacer,
            RowKind::Header("Pomodoro"),
            RowKind::Field(SettingsField::PomodoroWork),
            RowKind::Field(SettingsField::PomodoroBreak),
            RowKind::Field(SettingsField::PomodoroLongBreak),
            RowKind::Field(SettingsField::PomodoroSound),
            RowKind::Field(SettingsField::DesktopNotifications),
            RowKind::Spacer,
            RowKind::Header("Timer"),
            RowKind::Field(SettingsField::TimerDuration),
        ]
    }

    /// Get the row index of the currently selected field in the section layout.
    fn selected_field_row_index(&self) -> usize {
        Self::section_layout()
            .iter()
            .position(|row| matches!(row, RowKind::Field(f) if *f == self.selected_field))
            .unwrap_or(0)
    }

    /// Adjust scroll_offset so the selected field is within the visible window.
    fn ensure_visible(&mut self, visible_rows: u16) {
        let row_idx = self.selected_field_row_index() as u16;
        // Scroll up if selected field is above the visible window
        if row_idx < self.scroll_offset {
            self.scroll_offset = row_idx;
        }
        // Scroll down if selected field is below the visible window
        if row_idx >= self.scroll_offset + visible_rows {
            self.scroll_offset = row_idx.saturating_sub(visible_rows - 1);
        }
    }

    /// Select next value for current field.
    pub fn next_value(&mut self) {
        match self.selected_field {
            SettingsField::Font => {
                if !self.available_fonts.is_empty() {
                    self.font_index = (self.font_index + 1) % self.available_fonts.len();
                }
            }
            SettingsField::Color => {
                self.color_theme = self.color_theme.next();
            }
            SettingsField::TimeFormat => {
                self.time_format = self.time_format.toggle();
            }
            SettingsField::ShowSeconds => {
                self.show_seconds = !self.show_seconds;
            }
            SettingsField::Animation => {
                self.animation_style = self.animation_style.next();
            }
            SettingsField::Speed => {
                self.animation_speed = self.animation_speed.next();
            }
            SettingsField::Background => {
                self.background_style = self.background_style.next();
            }
            SettingsField::ColonBlink => {
                self.colon_blink = !self.colon_blink;
            }
            SettingsField::PomodoroWork => {
                // Cycle through common work durations: 15, 20, 25, 30, 45, 50, 60
                self.pomodoro_work_mins = match self.pomodoro_work_mins {
                    15 => 20,
                    20 => 25,
                    25 => 30,
                    30 => 45,
                    45 => 50,
                    50 => 60,
                    _ => 15,
                };
            }
            SettingsField::PomodoroBreak => {
                // Cycle through common break durations: 3, 5, 10, 15
                self.pomodoro_break_mins = match self.pomodoro_break_mins {
                    3 => 5,
                    5 => 10,
                    10 => 15,
                    _ => 3,
                };
            }
            SettingsField::PomodoroLongBreak => {
                // Cycle through common long break durations: 10, 15, 20, 30
                self.pomodoro_long_break_mins = match self.pomodoro_long_break_mins {
                    10 => 15,
                    15 => 20,
                    20 => 30,
                    _ => 10,
                };
            }
            SettingsField::PomodoroSound => {
                self.pomodoro_sound = !self.pomodoro_sound;
            }
            SettingsField::DesktopNotifications => {
                self.desktop_notifications = !self.desktop_notifications;
            }
            SettingsField::TimerDuration => {
                self.timer_duration_mins = (self.timer_duration_mins + 1).min(99);
            }
        }
    }

    /// Select previous value for current field.
    pub fn prev_value(&mut self) {
        match self.selected_field {
            SettingsField::Font => {
                if !self.available_fonts.is_empty() {
                    self.font_index = if self.font_index == 0 {
                        self.available_fonts.len() - 1
                    } else {
                        self.font_index - 1
                    };
                }
            }
            SettingsField::Color => {
                self.color_theme = self.color_theme.prev();
            }
            SettingsField::TimeFormat => {
                self.time_format = self.time_format.toggle();
            }
            SettingsField::ShowSeconds => {
                self.show_seconds = !self.show_seconds;
            }
            SettingsField::Animation => {
                self.animation_style = self.animation_style.prev();
            }
            SettingsField::Speed => {
                self.animation_speed = self.animation_speed.prev();
            }
            SettingsField::Background => {
                self.background_style = self.background_style.prev();
            }
            SettingsField::ColonBlink => {
                self.colon_blink = !self.colon_blink;
            }
            SettingsField::PomodoroWork => {
                // Cycle through common work durations (reverse): 60, 50, 45, 30, 25, 20, 15
                self.pomodoro_work_mins = match self.pomodoro_work_mins {
                    15 => 60,
                    20 => 15,
                    25 => 20,
                    30 => 25,
                    45 => 30,
                    50 => 45,
                    60 => 50,
                    _ => 25,
                };
            }
            SettingsField::PomodoroBreak => {
                // Cycle through common break durations (reverse): 15, 10, 5, 3
                self.pomodoro_break_mins = match self.pomodoro_break_mins {
                    3 => 15,
                    5 => 3,
                    10 => 5,
                    15 => 10,
                    _ => 5,
                };
            }
            SettingsField::PomodoroLongBreak => {
                // Cycle through common long break durations (reverse): 30, 20, 15, 10
                self.pomodoro_long_break_mins = match self.pomodoro_long_break_mins {
                    10 => 30,
                    15 => 10,
                    20 => 15,
                    30 => 20,
                    _ => 15,
                };
            }
            SettingsField::PomodoroSound => {
                self.pomodoro_sound = !self.pomodoro_sound;
            }
            SettingsField::DesktopNotifications => {
                self.desktop_notifications = !self.desktop_notifications;
            }
            SettingsField::TimerDuration => {
                self.timer_duration_mins = (self.timer_duration_mins.saturating_sub(1)).max(1);
            }
        }
    }

    /// Get currently selected font name.
    pub fn selected_font(&self) -> &str {
        self.available_fonts
            .get(self.font_index)
            .map(String::as_str)
            .unwrap_or("Standard")
    }

    /// Render the settings dialog.
    pub fn render(&mut self, frame: &mut Frame, area: Rect, accent_color: Color) {
        if !self.visible {
            return;
        }

        let layout = Self::section_layout();
        let total_content_rows = layout.len() as u16;

        // Proportional dialog sizing
        let dialog_width = 50.min(area.width.saturating_sub(4));
        // +5 for: border top/bottom (2) + help row (1) + top padding (1) + bottom padding (1)
        let dialog_height = (total_content_rows + 5).min(area.height.saturating_sub(2));

        let dialog_x = area.x + (area.width.saturating_sub(dialog_width)) / 2;
        let dialog_y = area.y + (area.height.saturating_sub(dialog_height)) / 2;
        let dialog_area = Rect::new(dialog_x, dialog_y, dialog_width, dialog_height);

        // Clear the area behind the dialog
        frame.render_widget(Clear, dialog_area);

        // Create block with border and explicit colors for light theme support
        let block = Block::default()
            .title(" Settings ")
            .title_alignment(Alignment::Center)
            .borders(Borders::ALL)
            .border_style(Style::default().fg(accent_color))
            .style(Style::default().fg(Color::White).bg(Color::Black));

        let inner_area = block.inner(dialog_area);
        frame.render_widget(block, dialog_area);

        // Split inner area with padding around content
        let chunks = Layout::vertical([
            Constraint::Length(1), // Top padding
            Constraint::Fill(1),   // Scrollable content area
            Constraint::Length(1), // Bottom padding
            Constraint::Length(1), // Help text
        ])
        .split(inner_area);

        // Add horizontal padding (2 chars each side)
        let content_area = Rect::new(
            chunks[1].x + 2,
            chunks[1].y,
            chunks[1].width.saturating_sub(4),
            chunks[1].height,
        );
        let visible_rows = content_area.height;

        // Ensure selected field is visible (adjust scroll)
        self.ensure_visible(visible_rows);

        // Determine if we need scroll indicators
        let can_scroll_up = self.scroll_offset > 0;
        let can_scroll_down = total_content_rows > self.scroll_offset + visible_rows;

        // Render content rows within the visible scroll window
        for (row_idx, row) in layout.iter().enumerate() {
            let row_idx = row_idx as u16;
            if row_idx < self.scroll_offset {
                continue;
            }
            let visible_y = row_idx - self.scroll_offset;
            if visible_y >= visible_rows {
                break;
            }

            let row_area = Rect::new(
                content_area.x,
                content_area.y + visible_y,
                content_area.width,
                1,
            );

            match row {
                RowKind::Header(name) => {
                    let header = self.render_section_header(name, accent_color);
                    frame.render_widget(
                        Paragraph::new(header).alignment(Alignment::Center),
                        row_area,
                    );
                }
                RowKind::Field(field) => {
                    let line = self.render_field_for(*field, accent_color);
                    frame
                        .render_widget(Paragraph::new(line).alignment(Alignment::Center), row_area);
                }
                RowKind::Spacer => {} // Empty row
            }
        }

        // Render scroll indicators over first/last content rows
        if can_scroll_up {
            let indicator = Line::from(Span::styled("", Style::default().fg(accent_color)));
            let indicator_area = Rect::new(
                content_area.x + content_area.width.saturating_sub(6),
                content_area.y,
                6,
                1,
            );
            frame.render_widget(
                Paragraph::new(indicator).alignment(Alignment::Right),
                indicator_area,
            );
        }
        if can_scroll_down {
            let indicator = Line::from(Span::styled("", Style::default().fg(accent_color)));
            let indicator_area = Rect::new(
                content_area.x + content_area.width.saturating_sub(6),
                content_area.y + visible_rows.saturating_sub(1),
                6,
                1,
            );
            frame.render_widget(
                Paragraph::new(indicator).alignment(Alignment::Right),
                indicator_area,
            );
        }

        // Render help text
        let help = Line::from(vec![
            Span::styled("↑↓", Style::default().fg(accent_color).bold()),
            Span::styled(" nav  ", Style::default().fg(Color::Gray)),
            Span::styled("←→", Style::default().fg(accent_color).bold()),
            Span::styled(" change  ", Style::default().fg(Color::Gray)),
            Span::styled("Enter", Style::default().fg(accent_color).bold()),
            Span::styled(" save  ", Style::default().fg(Color::Gray)),
            Span::styled("Esc", Style::default().fg(accent_color).bold()),
            Span::styled(" cancel", Style::default().fg(Color::Gray)),
        ]);
        frame.render_widget(Paragraph::new(help).alignment(Alignment::Center), chunks[3]);
    }

    /// Render a section header line.
    fn render_section_header(&self, name: &str, accent_color: Color) -> Line<'static> {
        Line::from(Span::styled(
            format!("── {name} ──"),
            Style::default().fg(accent_color).bold(),
        ))
    }

    /// Render the appropriate field line for a given SettingsField.
    fn render_field_for(&self, field: SettingsField, accent_color: Color) -> Line<'static> {
        let selected = self.selected_field == field;
        match field {
            SettingsField::Font => {
                self.render_field("Font", self.selected_font(), selected, accent_color)
            }
            SettingsField::Color => self.render_field(
                "Color",
                self.color_theme.display_name(),
                selected,
                accent_color,
            ),
            SettingsField::TimeFormat => {
                let name = match self.time_format {
                    TimeFormat::TwentyFourHour => "24-hour",
                    TimeFormat::TwelveHour => "12-hour",
                };
                self.render_field("Format", name, selected, accent_color)
            }
            SettingsField::ShowSeconds => {
                let v = if self.show_seconds { "On" } else { "Off" };
                self.render_field("Seconds", v, selected, accent_color)
            }
            SettingsField::ColonBlink => {
                let v = if self.colon_blink { "On" } else { "Off" };
                self.render_field("Colon Blink", v, selected, accent_color)
            }
            SettingsField::Animation => self.render_field(
                "Animation",
                self.animation_style.display_name(),
                selected,
                accent_color,
            ),
            SettingsField::Speed => self.render_field_with_style(
                "Speed",
                self.animation_speed.display_name(),
                selected,
                accent_color,
                self.animation_style != AnimationStyle::None,
            ),
            SettingsField::Background => self.render_field(
                "Background",
                self.background_style.display_name(),
                selected,
                accent_color,
            ),
            SettingsField::PomodoroWork => {
                let v = format!("{} min", self.pomodoro_work_mins);
                self.render_field("Work", &v, selected, accent_color)
            }
            SettingsField::PomodoroBreak => {
                let v = format!("{} min", self.pomodoro_break_mins);
                self.render_field("Break", &v, selected, accent_color)
            }
            SettingsField::PomodoroLongBreak => {
                let v = format!("{} min", self.pomodoro_long_break_mins);
                self.render_field("Long Break", &v, selected, accent_color)
            }
            SettingsField::PomodoroSound => {
                let v = if self.pomodoro_sound { "On" } else { "Off" };
                self.render_field("Sound", v, selected, accent_color)
            }
            SettingsField::DesktopNotifications => {
                let v = if self.desktop_notifications {
                    "On"
                } else {
                    "Off"
                };
                self.render_field("Notifications", v, selected, accent_color)
            }
            SettingsField::TimerDuration => {
                let v = format!("{} min", self.timer_duration_mins);
                self.render_field("Duration", &v, selected, accent_color)
            }
        }
    }

    /// Render a single settings field line.
    fn render_field(
        &self,
        label: &str,
        value: &str,
        selected: bool,
        accent_color: Color,
    ) -> Line<'static> {
        if selected {
            let arrow_style = Style::default().fg(accent_color).bold();
            let value_style = Style::default().fg(accent_color).bold();
            let label_style = Style::default().fg(accent_color);
            Line::from(vec![
                Span::styled(String::from(""), arrow_style),
                Span::styled(format!("{label}: "), label_style),
                Span::styled(String::from(""), arrow_style),
                Span::styled(value.to_string(), value_style),
                Span::styled(String::from(""), arrow_style),
            ])
        } else {
            let label_style = Style::default().fg(Color::Gray);
            let value_style = Style::default().fg(Color::White);
            Line::from(vec![
                Span::styled(String::from("  "), Style::default()),
                Span::styled(format!("{label}: "), label_style),
                Span::styled(value.to_string(), value_style),
            ])
        }
    }

    /// Render a single settings field line with enabled/disabled state.
    fn render_field_with_style(
        &self,
        label: &str,
        value: &str,
        selected: bool,
        accent_color: Color,
        enabled: bool,
    ) -> Line<'static> {
        if !enabled {
            // Grayed out when disabled - no arrows
            let gray = Style::default().fg(Color::DarkGray);
            return Line::from(vec![
                Span::styled(String::from("  "), Style::default()),
                Span::styled(format!("{label}: "), gray),
                Span::styled(value.to_string(), gray),
            ]);
        }

        self.render_field(label, value, selected, accent_color)
    }
}