/**
 * StratML Part 2 Form - Stylesheet
 * 
 * Modern, clean design with visual hierarchy for nested elements
 */

/* ========================================
   CSS VARIABLES
   ======================================== */
:root {
    /* Colors */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #6b7280;
    --success-color: #059669;
    --success-hover: #047857;
    --purple-color: #7c3aed;
    --purple-hover: #6d28d9;
    --warning-color: #d97706;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    
    /* Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-tertiary: #e5e7eb;
    --bg-highlight: #eff6ff;
    
    /* Borders */
    --border-color: #d1d5db;
    --border-focus: #2563eb;
    
    /* Text */
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Border radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
}

/* ========================================
   BASE STYLES
   ======================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-secondary);
    min-height: 100vh;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

/* ========================================
   HEADER
   ======================================== */
.form-header {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
}

.form-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
}

.form-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: var(--spacing-lg);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: var(--success-hover);
}

.btn-purple {
    background: var(--purple-color);
    color: white;
}

.btn-purple:hover {
    background: var(--purple-hover);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-add {
    background: var(--bg-highlight);
    color: var(--primary-color);
    border: 1px dashed var(--primary-color);
    width: 100%;
    padding: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.btn-add:hover {
    background: var(--primary-color);
    color: white;
    border-style: solid;
}

.btn-remove {
    background: transparent;
    color: var(--danger-color);
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.75rem;
    font-weight: bold;
    border: 1px solid var(--danger-color);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.btn-remove:hover {
    background: var(--danger-color);
    color: white;
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.4);
}

.btn-toggle {
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-color);
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 1rem;
    font-weight: bold;
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
}

.btn-toggle:hover {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.4);
}

.toggle-icon {
    font-size: 1rem;
    font-weight: bold;
    transition: transform var(--transition-fast);
}

/* Special styling for buttons in goal headers (blue background) */
.goal-header .btn-toggle {
    background: white;
    color: var(--primary-color);
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3);
}

    .goal-header .btn-toggle:hover {
    background: white;
    color: var(--danger-color);
    border: 2px solid var(--danger-color);
}

/* Goal header: make remove button red and visible by default */
.goal-header .btn-remove {
    background: var(--danger-color);
    color: white;
    border: 2px solid var(--danger-color);
    font-weight: bold;
}

.goal-header .btn-remove:hover {
    background: #b91c1c;
    color: white;
    border: 2px solid #b91c1c;
    box-shadow: 0 0 8px rgba(220,38,38,0.35);
}

.item-content.collapsed {
    display: none;
}

.btn-small {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.75rem;
}

.btn-tiny {
    padding: 2px 6px;
    font-size: 0.7rem;
}

/* Action Buttons Container */
.action-buttons {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
}

.top-buttons {
    margin-top: var(--spacing-lg);
}

.action-dropdown {
    position: relative;
}

.dropdown-trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.dropdown-caret {
    font-size: 0.75rem;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: var(--spacing-xs);
    z-index: 200;
}

.action-dropdown.open .dropdown-menu {
    display: block;
}

.dropdown-item {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    cursor: pointer;
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
    background: var(--bg-secondary);
    outline: none;
}

.bottom-buttons {
    background: var(--bg-primary);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    margin-top: var(--spacing-lg);
    box-shadow: var(--shadow-md);
}

/* ========================================
   FORM SECTIONS
   ======================================== */
.form-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.section-title {
    background: var(--bg-secondary);
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.section-title.collapsible {
    cursor: pointer;
    user-select: none;
}

.section-title.collapsible:hover {
    background: var(--bg-tertiary);
}

.collapse-icon {
    font-size: 0.75rem;
    transition: transform var(--transition-fast);
}

.section-content {
    padding: var(--spacing-lg);
}

.section-content.collapsed {
    display: none;
}

/* ========================================
   FORM ELEMENTS
   ======================================== */
.form-row {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-row.inline {
    align-items: center;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.form-group.full-width {
    flex: 1 0 100%;
}

label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.export-settings-label {
    font-weight: 700;
}

label.required::after {
    content: ' *';
    color: var(--danger-color);
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

textarea {
    resize: vertical;
    min-height: 60px;
}

input[type="file"] {
    padding: var(--spacing-sm);
    font-size: 0.875rem;
}

/* ========================================
   IMPORT SECTION
   ======================================== */
.import-section {
    border: 2px dashed var(--border-color);
    background: var(--bg-highlight);
}

.import-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
}

.import-option {
    padding: var(--spacing-md);
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.import-option h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.import-option p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.url-input-group {
    display: flex;
    gap: var(--spacing-sm);
}

.url-input-group input {
    flex: 1;
}

/* ========================================
   STATUS MESSAGES
   ======================================== */
.status-message {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-top: var(--spacing-md);
}

.status-message.hidden {
    display: none;
}

.status-message.info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.status-message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.status-message.warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.status-message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* ========================================
   REPEATING ITEMS
   ======================================== */
.repeating-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.repeating-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    overflow: hidden;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    gap: var(--spacing-sm);
}

.item-header.compact {
    padding: var(--spacing-xs) var(--spacing-sm);
}

.button-group {
    display: flex;
    gap: var(--spacing-xs);
    align-items: center;
    flex-shrink: 0;
}

.item-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.item-content {
    padding: var(--spacing-md);
}

/* Nested Sections */
.nested-section {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.nested-section h4,
.nested-section h5,
.nested-section h6 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-sm);
}

.nested-section.level-2 {
    background: var(--bg-tertiary);
}

.nested-section.level-3 {
    background: #f0f0f0;
}

/* ========================================
   GOALS & OBJECTIVES
   ======================================== */
.goals-section .section-content {
    background: var(--bg-highlight);
}

.goal-item {
    border: 2px solid var(--primary-color);
}

.goal-header {
    background: var(--primary-color);
    color: white;
}

.goal-header .item-title {
    color: white;
}

/* Ensure goal remove button remains red/visible by default (override earlier rules) */
.goal-header .btn-remove {
    background: var(--danger-color);
    color: white;
    border: 2px solid var(--danger-color);
    font-weight: bold;
}

.goal-header .btn-remove:hover {
    background: #b91c1c;
    color: white;
}

.objective-item {
    border-color: #60a5fa;
    margin-left: var(--spacing-md);
}

.objective-header {
    background: #dbeafe;
}

/* Performance Indicators */
.pi-item {
    border-color: #a78bfa;
}

.pi-header {
    background: #ede9fe;
}

/* Measurement Section */
.measurement-item {
    border-color: var(--success-color);
}

.result-section {
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    border-radius: var(--radius-sm);
}

.result-section h6 {
    font-size: 0.7rem;
    margin-bottom: var(--spacing-xs);
}

.target-section {
    background: #dcfce7;
}

.actual-section {
    background: #dbeafe;
}

.result-row {
    display: flex;
    gap: var(--spacing-sm);
    align-items: flex-end;
    flex-wrap: wrap;
}

.result-row .form-group {
    flex: 0 0 auto;
    min-width: 100px;
}

.result-row label {
    font-size: 0.65rem;
}

.result-row input {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.75rem;
}

/* ========================================
   FOOTER
   ======================================== */
.form-footer {
    text-align: center;
    padding: var(--spacing-lg);
    color: var(--text-muted);
    font-size: 0.75rem;
}

.form-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.form-footer a:hover {
    text-decoration: underline;
}

.autosave-status {
    margin-top: var(--spacing-sm);
    font-style: italic;
}

/* ========================================
   FORM NOTES
   ======================================== */
.form-note {
    background: var(--bg-secondary);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.form-note p {
    margin-bottom: var(--spacing-xs);
}

.form-note p:last-child {
    margin-bottom: 0;
}

.stylesheet-download-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-xs);
}

.stylesheet-download-row {
    --stylesheet-accent: var(--border-color);
    --stylesheet-tint: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    padding: var(--spacing-sm);
    border: 1px solid var(--border-color);
    border-left-width: 6px;
    border-left-color: var(--stylesheet-accent);
    border-radius: var(--radius-md);
    background: #ffffff;
}

.stylesheet-download-row[data-stylesheet="default"] {
    --stylesheet-accent: #2563eb;
    --stylesheet-tint: #e8f0ff;
}

.stylesheet-download-row[data-stylesheet="shakib"] {
    --stylesheet-accent: #0f766e;
    --stylesheet-tint: #e6fffb;
}

.stylesheet-download-row[data-stylesheet="hesham"] {
    --stylesheet-accent: #7c3aed;
    --stylesheet-tint: #f3e8ff;
}

.stylesheet-download-row[data-stylesheet="pulkit"] {
    --stylesheet-accent: #d97706;
    --stylesheet-tint: #fff4e5;
}

.stylesheet-download-name {
    display: inline-flex;
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--stylesheet-accent);
    border-radius: 999px;
    background: var(--stylesheet-tint);
    font-weight: 600;
    color: var(--stylesheet-accent);
}

.stylesheet-download-actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.stylesheet-download-actions .btn {
    padding: var(--spacing-xs) var(--spacing-md);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-md);
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-group.full-width {
        flex: 1;
    }
    
    .import-options {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
    }

    .action-dropdown {
        width: 100%;
    }

    .dropdown-trigger {
        width: 100%;
        justify-content: center;
    }

    .dropdown-menu {
        width: 100%;
        min-width: 0;
        left: 0;
    }
    
    .url-input-group {
        flex-direction: column;
    }
    
    .result-row {
        flex-direction: column;
    }
    
    .result-row .form-group {
        width: 100%;
    }

    .stylesheet-download-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .stylesheet-download-actions {
        width: 100%;
    }

    .stylesheet-download-actions .btn {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .form-header h1 {
        font-size: 1.25rem;
    }
    
    .section-title {
        font-size: 0.875rem;
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .section-content {
        padding: var(--spacing-md);
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.repeating-item {
    animation: fadeIn var(--transition-normal);
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .action-buttons,
    .btn-add,
    .btn-remove,
    .import-section {
        display: none !important;
    }
    
    .form-section {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .section-content.collapsed {
        display: block !important;
    }
}
