/* ============================================================
   ENHANCED MODAL STYLES - Improved Design
   Insert these styles into the <style> section of index.html
   to replace or enhance existing modal styles
============================================================ */

/* ===== MODAL STEP PROGRESS - Enhanced ===== */
.modal-step {
    flex: 1;
    text-align: center;
    opacity: 0.4;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.modal-step::after {
    content: '';
    position: absolute;
    top: 16px;
    left: 60%;
    right: -40%;
    height: 3px;
    background: #E5E7EB;
    z-index: -1;
    transition: background 0.4s ease;
}

.modal-step:last-child::after {
    display: none;
}

.modal-step.completed::after {
    background: var(--ion-color-success);
}

.modal-step.active {
    opacity: 1;
    transform: scale(1.05);
}

.modal-step.completed {
    opacity: 1;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #E5E7EB, #D1D5DB);
    color: #6B7280;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 6px;
    font-weight: 800;
    font-size: 16px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1;
}

.modal-step.active .step-number {
    background: linear-gradient(135deg, var(--ion-color-primary), #7AD63A);
    color: #064E3B;
    transform: scale(1.15);
    box-shadow: 0 4px 16px rgba(159,236,83,0.5), 0 0 0 4px rgba(159,236,83,0.2);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(159,236,83,0.5), 0 0 0 4px rgba(159,236,83,0.2);
    }
    50% {
        box-shadow: 0 4px 20px rgba(159,236,83,0.6), 0 0 0 6px rgba(159,236,83,0.15);
    }
}

.modal-step.completed .step-number {
    background: linear-gradient(135deg, var(--ion-color-success), #16A34A);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 3px 12px rgba(34,197,94,0.4);
}

.modal-step.completed .step-number::before {
    content: '✓';
    position: absolute;
    font-size: 20px;
    font-weight: 900;
}

.step-label {
    font-size: 12px;
    font-weight: 700;
    color: #9CA3AF;
    transition: all 0.3s ease;
    letter-spacing: 0.02em;
}

.modal-step.active .step-label {
    color: var(--ion-color-primary);
    transform: scale(1.05);
}

.modal-step.completed .step-label {
    color: var(--ion-color-success);
}

/* ===== STEP CONTENT - Enhanced Animation ===== */
.modal-step-content {
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== DEVICE TYPE GRID - Premium Design ===== */
.device-type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-top: 20px;
    padding: 0 4px;
}

.device-type-card {
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    border: 2px solid #E5E7EB;
    border-radius: 20px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.device-type-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at top right, rgba(159,236,83,0.1), transparent);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.device-type-card:hover::before {
    opacity: 1;
}

.device-type-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.12);
    border-color: rgba(159,236,83,0.5);
}

.device-type-card:active {
    transform: translateY(-2px) scale(0.98);
}

.device-type-card.selected {
    border-color: var(--ion-color-primary);
    background: linear-gradient(135deg, #F1FEE7, #E8F9E8);
    box-shadow: 
        0 8px 24px rgba(159,236,83,0.25),
        0 0 0 4px rgba(159,236,83,0.1),
        inset 0 1px 0 rgba(255,255,255,0.5);
    transform: translateY(-4px) scale(1.02);
}

.device-type-card.selected::before {
    opacity: 0.5;
}

.device-type-icon {
    font-size: 56px;
    margin-bottom: 10px;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.1));
}

.device-type-card:hover .device-type-icon {
    transform: scale(1.1) rotate(5deg);
}

.device-type-card.selected .device-type-icon {
    transform: scale(1.15);
    animation: iconBounce 0.6s ease;
}

@keyframes iconBounce {
    0%, 100% { transform: scale(1.15) translateY(0); }
    50% { transform: scale(1.2) translateY(-4px); }
}

.device-type-name {
    font-weight: 800;
    font-size: 16px;
    margin-bottom: 6px;
    color: #0F172A;
    letter-spacing: -0.02em;
}

.device-type-card.selected .device-type-name {
    color: #064E3B;
}

.device-type-desc {
    font-size: 12px;
    color: #64748B;
    line-height: 1.4;
}

.device-type-card.selected .device-type-desc {
    color: #14532D;
    font-weight: 500;
}

/* ===== FORM ITEMS - Enhanced ===== */
ion-item {
    --padding-start: 0;
    --inner-padding-end: 0;
    --border-width: 0;
    --border-color: transparent;
    margin-bottom: 16px;
    border-radius: 14px;
    --background: #F8FAFC;
    border: 2px solid #E5E7EB;
    transition: all 0.3s ease;
}

ion-item:focus-within {
    --background: white;
    border-color: var(--ion-color-primary);
    box-shadow: 0 0 0 4px rgba(159,236,83,0.1), 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

ion-item ion-icon {
    color: var(--ion-color-secondary);
    margin-right: 8px;
    font-size: 20px;
}

ion-label {
    font-weight: 600;
    font-size: 14px;
    color: #475569;
}

ion-input {
    --padding-start: 12px;
    --padding-end: 12px;
    font-size: 15px;
}

ion-select {
    --padding-start: 12px;
    font-size: 15px;
}

ion-item-divider {
    font-weight: 800;
    font-size: 14px;
    margin-top: 24px;
    margin-bottom: 12px;
    --background: transparent;
    --padding-start: 0;
    color: #0F172A;
    letter-spacing: -0.01em;
}

ion-item-divider::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 16px;
    background: linear-gradient(135deg, var(--ion-color-primary), var(--ion-color-secondary));
    border-radius: 2px;
    margin-right: 8px;
    vertical-align: middle;
}

/* ===== TOGGLE ITEMS - Enhanced ===== */
ion-toggle {
    --background: #D1D5DB;
    --background-checked: var(--ion-color-primary);
    --handle-background: white;
    --handle-background-checked: #064E3B;
    --handle-box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ===== MODAL FOOTER BUTTONS - Enhanced ===== */
#modal-back-btn {
    --border-width: 2px;
    --border-color: #E5E7EB;
    font-weight: 700;
    height: 48px;
    --border-radius: 14px;
    transition: all 0.3s ease;
}

#modal-back-btn:hover {
    --border-color: var(--ion-color-primary);
    --color: var(--ion-color-primary);
    transform: translateX(-4px);
}

#modal-next-btn,
#modal-save-btn {
    height: 48px;
    font-weight: 800;
    --border-radius: 14px;
    box-shadow: 0 4px 12px rgba(159,236,83,0.3);
    transition: all 0.3s ease;
}

#modal-next-btn:hover,
#modal-save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(159,236,83,0.4);
}

#modal-next-btn:active,
#modal-save-btn:active {
    transform: translateY(0);
}

/* ===== INFO BOX - New Component ===== */
.info-box {
    background: linear-gradient(135deg, rgba(59,130,246,0.1), rgba(37,99,235,0.05));
    border: 1px solid rgba(59,130,246,0.2);
    border-radius: 14px;
    padding: 14px;
    margin: 16px 0;
    display: flex;
    gap: 12px;
    align-items: start;
}

.info-box ion-icon {
    color: #3B82F6;
    font-size: 24px;
    flex-shrink: 0;
}

.info-box-content {
    flex: 1;
}

.info-box-title {
    font-weight: 700;
    font-size: 13px;
    color: #1E40AF;
    margin-bottom: 4px;
}

.info-box-text {
    font-size: 12px;
    color: #475569;
    line-height: 1.5;
    margin: 0;
}

/* ===== SUCCESS BOX - New Component ===== */
.success-box {
    background: linear-gradient(135deg, rgba(159,236,83,0.15), rgba(122,214,58,0.08));
    border: 2px solid rgba(159,236,83,0.3);
    border-radius: 20px;
    padding: 32px 24px;
    text-align: center;
    margin: 20px 0;
}

.success-box ion-icon {
    font-size: 72px;
    color: var(--ion-color-primary);
    margin-bottom: 16px;
    animation: successPulse 2s ease-in-out infinite;
}

@keyframes successPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.08);
        opacity: 0.9;
    }
}

.success-box h4 {
    font-size: 22px;
    font-weight: 800;
    color: #064E3B;
    margin: 0 0 8px 0;
    letter-spacing: -0.02em;
}

.success-box p {
    font-size: 14px;
    color: #14532D;
    margin: 0;
    line-height: 1.5;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 576px) {
    .device-type-grid {
        gap: 10px;
    }
    
    .device-type-card {
        padding: 18px 12px;
        border-radius: 16px;
    }
    
    .device-type-icon {
        font-size: 48px;
        margin-bottom: 8px;
    }
    
    .device-type-name {
        font-size: 14px;
    }
    
    .device-type-desc {
        font-size: 11px;
    }
    
    .step-number {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    .step-label {
        font-size: 10px;
    }
}

@media (max-width: 380px) {
    .device-type-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .device-type-card {
        display: flex;
        align-items: center;
        text-align: left;
        padding: 16px;
    }
    
    .device-type-icon {
        font-size: 42px;
        margin-bottom: 0;
        margin-right: 16px;
    }
}

/* ===== LOADING STATE ===== */
.modal-step-content.loading {
    opacity: 0.6;
    pointer-events: none;
    filter: blur(2px);
}

/* ===== SMOOTH TRANSITIONS ===== */
* {
    -webkit-tap-highlight-color: transparent;
}

ion-modal {
    --backdrop-opacity: 0.6;
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    .device-type-card {
        background: linear-gradient(135deg, #1F2937, #111827);
        border-color: #374151;
    }
    
    .device-type-card.selected {
        background: linear-gradient(135deg, rgba(159,236,83,0.2), rgba(122,214,58,0.15));
        border-color: var(--ion-color-primary);
    }
    
    .device-type-name {
        color: #F3F4F6;
    }
    
    .device-type-desc {
        color: #9CA3AF;
    }
    
    ion-item {
        --background: #1F2937;
        border-color: #374151;
    }
    
    ion-item:focus-within {
        --background: #111827;
    }
    
    ion-label {
        color: #D1D5DB;
    }
}
/* ===================================================
   AUTOMATION RULE MODAL – MOBILE PRO UI
=================================================== */

#automationRuleModal {
    --height: 95%;
    --border-radius: 18px 18px 0 0;
}

/* ---------- HEADER ---------- */
#automationRuleModal ion-toolbar {
    --background: #ffffff;
    border-bottom: 1px solid #E5E7EB;
}

#automationRuleModal ion-title {
    font-weight: 800;
    font-size: 17px;
    color: #0F172A;
}

/* ---------- PROGRESS ---------- */
.ar-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 12px;
    gap: 6px;
    background: #F8FAFC;
}

.ar-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    color: #9CA3AF;
    min-width: 70px;
    transition: all .3s ease;
}

.ar-dot {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #E5E7EB;
    color: #6B7280;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    font-weight: 800;
    transition: all .3s ease;
}

/* active */
.ar-step.active {
    color: var(--ion-color-primary);
}

.ar-step.active .ar-dot {
    background: linear-gradient(135deg, var(--ion-color-primary), #7AD63A);
    color: #064E3B;
    box-shadow: 0 0 0 4px rgba(159,236,83,.2);
}

/* done */
.ar-step.done {
    color: var(--ion-color-success);
}

.ar-step.done .ar-dot {
    background: var(--ion-color-success);
    color: #fff;
}

.ar-step.done .ar-dot::before {
    content: "✓";
}

/* line */
.ar-line {
    flex: 1;
    height: 3px;
    background: #E5E7EB;
    border-radius: 3px;
}

.ar-step.done + .ar-line {
    background: var(--ion-color-success);
}

/* ---------- CONTENT ---------- */
#automationRuleModal ion-content {
    --background: #F6F8FB;
}

.step-content {
    display: none;
    padding: 16px;
    animation: arFadeUp .35s ease;
}

.step-content.active {
    display: block;
}

@keyframes arFadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.step-title {
    font-size: 15px;
    font-weight: 800;
    margin-bottom: 12px;
    color: #0F172A;
}

/* ---------- FORM ---------- */
#automationRuleModal ion-item {
    --background: #ffffff;
    border-radius: 14px;
    border: 2px solid #E5E7EB;
    margin-bottom: 14px;
    transition: all .25s ease;
}

#automationRuleModal ion-item:focus-within {
    border-color: var(--ion-color-primary);
    box-shadow: 0 0 0 4px rgba(159,236,83,.15);
}

#automationRuleModal ion-label {
    font-weight: 600;
    color: #475569;
}

#automationRuleModal ion-input,
#automationRuleModal ion-select {
    font-size: 15px;
}

/* ---------- SUMMARY ---------- */
.info-box {
    background: linear-gradient(135deg,#EEF2FF,#F8FAFC);
    border: 1px solid #C7D2FE;
    border-radius: 14px;
    padding: 14px;
    display: flex;
    gap: 12px;
}

.info-box ion-icon {
    font-size: 26px;
    color: #6366F1;
}

.info-box-title {
    font-weight: 800;
    font-size: 13px;
    margin-bottom: 4px;
}

/* ---------- FOOTER ---------- */
.modal-footer {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.modal-footer ion-button {
    flex: 1;
    height: 46px;
    font-weight: 800;
    --border-radius: 14px;
}

/* sticky footer on mobile */
@media (max-width: 576px) {
    .modal-footer {
        position: sticky;
        bottom: 0;
        background: #F6F8FB;
        padding: 12px 0 4px;
    }
}
/* ===================================================
   AUTOMATION RULE MODAL – MOBILE PRO UI
=================================================== */

#automationRuleModal {
    --height: 95%;
    --border-radius: 18px 18px 0 0;
}

/* ---------- HEADER ---------- */
#automationRuleModal ion-toolbar {
    --background: #ffffff;
    border-bottom: 1px solid #E5E7EB;
}

#automationRuleModal ion-title {
    font-weight: 800;
    font-size: 17px;
    color: #0F172A;
}

/* ---------- PROGRESS ---------- */
.ar-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 12px;
    gap: 6px;
    background: #F8FAFC;
}

.ar-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    color: #9CA3AF;
    min-width: 70px;
    transition: all .3s ease;
}

.ar-dot {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #E5E7EB;
    color: #6B7280;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    font-weight: 800;
    transition: all .3s ease;
}

/* active */
.ar-step.active {
    color: var(--ion-color-primary);
}

.ar-step.active .ar-dot {
    background: linear-gradient(135deg, var(--ion-color-primary), #7AD63A);
    color: #064E3B;
    box-shadow: 0 0 0 4px rgba(159,236,83,.2);
}

/* done */
.ar-step.done {
    color: var(--ion-color-success);
}

.ar-step.done .ar-dot {
    background: var(--ion-color-success);
    color: #fff;
}

.ar-step.done .ar-dot::before {
    content: "✓";
}

/* line */
.ar-line {
    flex: 1;
    height: 3px;
    background: #E5E7EB;
    border-radius: 3px;
}

.ar-step.done + .ar-line {
    background: var(--ion-color-success);
}

/* ---------- CONTENT ---------- */
#automationRuleModal ion-content {
    --background: #F6F8FB;
}

.step-content {
    display: none;
    padding: 16px;
    animation: arFadeUp .35s ease;
}

.step-content.active {
    display: block;
}

@keyframes arFadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.step-title {
    font-size: 15px;
    font-weight: 800;
    margin-bottom: 12px;
    color: #0F172A;
}

/* ---------- FORM ---------- */
#automationRuleModal ion-item {
    --background: #ffffff;
    border-radius: 14px;
    border: 2px solid #E5E7EB;
    margin-bottom: 14px;
    transition: all .25s ease;
}

#automationRuleModal ion-item:focus-within {
    border-color: var(--ion-color-primary);
    box-shadow: 0 0 0 4px rgba(159,236,83,.15);
}

#automationRuleModal ion-label {
    font-weight: 600;
    color: #475569;
}

#automationRuleModal ion-input,
#automationRuleModal ion-select {
    font-size: 15px;
}

/* ---------- SUMMARY ---------- */
.info-box {
    background: linear-gradient(135deg,#EEF2FF,#F8FAFC);
    border: 1px solid #C7D2FE;
    border-radius: 14px;
    padding: 14px;
    display: flex;
    gap: 12px;
}

.info-box ion-icon {
    font-size: 26px;
    color: #6366F1;
}

.info-box-title {
    font-weight: 800;
    font-size: 13px;
    margin-bottom: 4px;
}

/* ---------- FOOTER ---------- */
.modal-footer {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.modal-footer ion-button {
    flex: 1;
    height: 46px;
    font-weight: 800;
    --border-radius: 14px;
}

/* sticky footer on mobile */
@media (max-width: 576px) {
    .modal-footer {
        position: sticky;
        bottom: 0;
        background: #F6F8FB;
        padding: 12px 0 4px;
    }
}
