/* Material Design 3.0 Components - Clean Version */
/* Consolidated: Text Fields, Switch, and Modal styles */

/* === TEXT FIELDS === */
.md-text-field {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 56px;
    border-radius: 8px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    box-shadow: none;
}

/* Auto-float label for date/time inputs */
.md-text-field input[type="date"] + .md-text-field-label,
.md-text-field input[type="time"] + .md-text-field-label {
    top: 0;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--primary);
}

.md-text-field:focus-within {
    border-color: var(--primary);
    border-width: 2px;
}

.md-text-field:hover:not(.md-text-field-disabled) {
    border-color: var(--border-hover);
}

.md-text-field-input {
    flex: 1;
    padding: 16px 16px 8px 16px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.5;
    box-shadow: none;
    width: auto;
    min-height: auto;
}

.md-text-field-label {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.5;
    pointer-events: none;
    transition: all 0.3s ease;
    background: var(--bg-card);
    padding: 0 4px;
    margin: 0;
    font-weight: normal;
    white-space: nowrap;
}

.md-text-field:focus-within .md-text-field-label,
.md-text-field.md-text-field-populated .md-text-field-label {
    top: 0;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--primary);
}

/* Textarea variant */
.md-text-field-textarea {
    min-height: 80px;
    align-items: flex-start;
}

.md-text-field-textarea .md-text-field-input {
    padding-top: 24px;
    padding-bottom: 16px;
    min-height: 48px;
    resize: vertical;
}

.md-text-field-textarea .md-text-field-label {
    top: 20px;
}

.md-text-field-textarea:focus-within .md-text-field-label,
.md-text-field-textarea.md-text-field-populated .md-text-field-label {
    top: 8px;
}

/* Select variant */
.md-text-field-select::after {
    content: '▼';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 12px;
    pointer-events: none;
    transition: transform 0.3s ease;
}

.md-text-field-select:focus-within::after {
    transform: translateY(-50%) rotate(180deg);
}

/* Error state */
.md-text-field-error {
    border-color: var(--error);
}

.md-text-field-error .md-text-field-label {
    color: var(--error);
}

.md-text-field-error:focus-within .md-text-field-label {
    color: var(--error);
}

/* Disabled state */
.md-text-field-disabled {
    border-color: var(--border-color);
    opacity: 0.5;
    pointer-events: none;
}

/* === SWITCH === */
.md-switch {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    margin-bottom: 24px;
}

.md-switch-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.md-switch-track {
    position: relative;
    width: 52px;
    height: 32px;
    border-radius: 16px;
    background-color: var(--bg-hover);
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.md-switch-handle {
    position: absolute;
    top: 50%;
    left: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--text-primary);
    transform: translateY(-50%);
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.md-switch-state-layer {
    display: none;
}

.md-switch-input:checked + .md-switch-track {
    background-color: var(--primary);
    border-color: var(--primary);
}

.md-switch-input:checked + .md-switch-track .md-switch-handle {
    left: calc(100% - 26px);
    width: 24px;
    height: 24px;
    background-color: white;
}

.md-switch-label {
    margin-left: 12px;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: normal;
}

/* === MODAL INTEGRATION === */
.modal-container {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    min-width: 400px;
    max-width: 600px;
    width: 90vw;
    max-height: 85vh;
    overflow: hidden;
    border: none;
}

.modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 400;
    line-height: 1.3;
    margin: 0;
}

.modal-close {
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--bg-hover);
}

.modal-body {
    padding: 24px;
    max-height: 65vh;
    overflow-y: auto;
}

.modal-body .form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.modal-body .form-group {
    flex: 1;
    min-width: 0;
}

.modal-body .md-text-field {
    margin-bottom: 16px;
}

.modal-body .md-switch {
    margin-bottom: 24px;
}

.modal-footer {
    padding: 16px 24px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-footer .btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.modal-footer .btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}

.modal-footer .btn-secondary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border-color);
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-footer .btn-secondary:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .modal-container {
        min-width: 320px;
        width: 95vw;
        max-height: 90vh;
    }
    
    .modal-body .form-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .modal-footer {
        flex-direction: column-reverse;
        gap: 12px;
    }
    
    .modal-footer .btn-primary,
    .modal-footer .btn-secondary {
        width: 100%;
    }
}

/* === CHECKBOXES === */
.md-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
    padding: 0.5rem 0;
}

.md-checkbox-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.md-checkbox-background {
    position: relative;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-card);
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.md-checkbox-checkmark {
    width: 12px;
    height: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.md-checkbox-input:checked + .md-checkbox-background {
    background: var(--primary);
    border-color: var(--primary);
}

.md-checkbox-input:checked + .md-checkbox-background .md-checkbox-checkmark {
    opacity: 1;
}

.md-checkbox:hover .md-checkbox-background {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.md-checkbox-input:checked + .md-checkbox-background:hover {
    background: var(--primary);
    opacity: 0.9;
}

.md-checkbox-label {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.4;
    cursor: pointer;
    flex: 1;
}

.md-checkbox-input:disabled + .md-checkbox-background {
    background: var(--bg-disabled);
    border-color: var(--border-disabled);
    cursor: not-allowed;
}

.md-checkbox-input:disabled ~ .md-checkbox-label {
    color: var(--text-disabled);
    cursor: not-allowed;
}