/* automation.css - Automation buttons section */

.automation-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 24px;
    max-width: 100vw;
}

/* ===== TOP TABS: Pulsanti / Scanner ===== */

.automation-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.automation-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.automation-tab:hover {
    color: var(--text);
}

.automation-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.automation-tab svg {
    flex-shrink: 0;
}

.automation-tab-content {
    flex: 1;
    min-height: 0;
}

.automation-header {
    margin-bottom: 24px;
}
.automation-header h3 {
    font-size: 20px;
    font-weight: 600;
}
.automation-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}
.automation-filters {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.automation-playlists-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    grid-column: 1 / -1;
}

/* Square playlist card */
.auto-playlist-sq-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    aspect-ratio: 1;
    padding: 16px 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 16px;
    background: var(--bg);
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}
.auto-playlist-sq-card:active {
    transform: scale(0.96);
}
.auto-playlist-sq-card:hover {
    border-color: var(--card-color, var(--success));
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.auto-playlist-sq-card .auto-sq-menu {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}
.auto-playlist-sq-card:hover .auto-sq-menu {
    opacity: 1;
}
@media (hover: none) {
    .auto-playlist-sq-card .auto-sq-menu { opacity: 0.6; }
}
@media (max-width: 768px) {
    .auto-playlist-sq-card .auto-sq-menu { opacity: 0.5; }
    .automation-container {
        padding-bottom: calc(24px + 60px + env(safe-area-inset-bottom, 0px));
    }
    #screen-mail .automation-container {
        padding-bottom: 0;
    }
}

/* Button grid - 2 column square cards */
.automation-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    overflow-x: hidden;
}

.automation-grid.buttons-row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 16px;
    padding: 8px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.automation-grid.buttons-row::-webkit-scrollbar {
    display: none;
}

.automation-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    grid-column: 1 / -1;
    width: 100%;
}
.automation-empty p {
    font-size: 14px;
    color: var(--text-tertiary);
    margin: 12px 0 20px;
    max-width: 360px;
}

/* Automation card */
.automation-card {
    display: flex;
    flex-direction: column;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg);
    transition: all var(--transition);
}
.automation-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.automation-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.automation-card-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

.automation-card-menu {
    opacity: 0;
    transition: opacity var(--transition);
}
.automation-card:hover .automation-card-menu { opacity: 1; }

.automation-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.automation-card-type {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

.btn-execute {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: auto;
}
.btn-execute:hover { opacity: 0.9; transform: scale(1.02); }

/* WhatsApp/Email action buttons in result modal */
.btn-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    margin-top: 12px;
    background: #25D366;
    color: white;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: opacity var(--transition);
}
.btn-whatsapp:hover { opacity: 0.9; }

.btn-email {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    margin-top: 8px;
    background: var(--info);
    color: white;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: opacity var(--transition);
}
.btn-email:hover { opacity: 0.9; }

/* Automation preview in confirm modal */
.automation-preview {
    text-align: center;
    padding: 20px 0;
}
.automation-preview-icon {
    display: inline-flex;
    width: 56px;
    height: 56px;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
}
.automation-preview h4 {
    font-size: 18px;
    font-weight: 600;
}
.automation-preview-type {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    background: var(--bg-tertiary);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 8px 0 16px;
}
.automation-preview p {
    text-align: left;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
}
.automation-preview-note {
    text-align: center;
    font-size: 14px;
    color: var(--text);
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Loading in result modal */
.automation-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 0;
}
.automation-loading p { color: var(--text-secondary); font-size: 14px; }

.automation-result-text {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
}

.text-error { color: var(--error); }
.text-info { color: var(--info); font-size: 13px; font-style: italic; }

/* Input automation cards */
.automation-card-with-input {
    min-height: auto;
}
.automation-input-area {
    margin: 8px 0 12px;
}
.automation-text-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text);
    resize: vertical;
    min-height: 44px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.automation-text-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg);
}
.automation-text-input::placeholder {
    color: var(--text-tertiary);
}

.automation-file-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-secondary);
    min-height: 44px;
}
.automation-file-input:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.automation-file-placeholder {
    font-size: 13px;
    color: var(--text-tertiary);
}
.automation-file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.automation-file-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}
.automation-file-clear:hover {
    background: var(--error);
    color: white;
}

/* Disabled execute button */
.btn-execute:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    transform: none !important;
}

/* Result input label */
.automation-result-input-label {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

/* File download result */
.automation-file-download {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    margin-top: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.automation-file-download-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}
.automation-file-download-info div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.automation-file-download-info strong {
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.automation-file-download-info .text-muted {
    font-size: 12px;
    color: var(--text-tertiary);
}
.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: #4A8C6F;
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}
.btn-download:hover {
    background: #4A8C6F;
    transform: scale(1.02);
}

/* Success state after button creation */
.automation-created-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 0;
    gap: 8px;
}
.automation-created-success h4 {
    font-size: 18px;
    font-weight: 600;
    color: #4A8C6F;
    margin-top: 4px;
}
.automation-created-success p {
    font-size: 14px;
    color: var(--text-secondary);
}

.automation-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin-bottom: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
}

/* Conditional button hints */
.conditional-hints {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.conditional-hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 16px;
    background: var(--bg-tertiary);
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--border);
}
.conditional-hint:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}
.conditional-hint strong {
    color: var(--text);
    font-weight: 700;
}

/* Schedule badge on card */
.schedule-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    background: #B8860B20;
    color: #92400E;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 8px;
}
[data-theme="dark"] .schedule-badge {
    background: #78350F;
    color: #FBBF24;
}
.schedule-badge svg {
    flex-shrink: 0;
}

/* Schedule modal options */
.schedule-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.schedule-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
}
.schedule-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.schedule-option input[type="radio"] {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.schedule-option-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.schedule-option-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.schedule-option-desc {
    font-size: 12px;
    color: var(--text-tertiary);
}

.schedule-details {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.schedule-details select,
.schedule-details input[type="time"],
.schedule-details input[type="datetime-local"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg-secondary);
    color: var(--text);
    font-family: inherit;
}
.schedule-details select:focus,
.schedule-details input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Schedule input section */
.schedule-input-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0 12px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}
.schedule-input-divider::before,
.schedule-input-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
#schedule-input-text {
    width: 100%;
    resize: vertical;
    min-height: 80px;
}
.schedule-file-upload {
    display: flex;
    align-items: center;
    gap: 10px;
}
.schedule-filename {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.schedule-saved-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(74,140,111,0.1);
    border-radius: 8px;
    color: #4A8C6F;
    font-size: 13px;
    font-weight: 500;
}

/* Day of week chips */
.day-chips {
    display: flex;
    gap: 6px;
}
.day-chip {
    flex: 1;
    padding: 10px 0;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}
.day-chip:active {
    transform: scale(0.95);
}
.day-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

/* Day of month grid */
.day-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}
.day-grid-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
}
.day-grid-cell:active {
    transform: scale(0.92);
}
.day-grid-cell.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

/* ===== Add button card ===== */
.auto-add-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    min-height: 140px;
    padding: 16px 10px 12px;
    border: 2px dashed var(--border);
    border-radius: 16px;
    background: var(--bg);
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    color: var(--text-secondary);
    gap: 8px;
}
.auto-add-card:active {
    transform: scale(0.96);
}
.auto-add-card:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.auto-add-card span {
    font-size: 12px;
    font-weight: 500;
}

/* ===== Square card style ===== */
.auto-sq-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    width: 100%;
    min-height: 140px;
    padding: 52px 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 16px;
    background: var(--bg);
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}
.auto-sq-card:active {
    transform: scale(0.96);
}
.auto-sq-card:hover {
    border-color: var(--card-color, var(--primary));
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.auto-sq-menu {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}
.auto-sq-card:hover .auto-sq-menu {
    opacity: 1;
}
/* Always show on mobile (no hover) */
@media (hover: none) {
    .auto-sq-menu { opacity: 0.7; }
}
.auto-sq-menu .btn-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auto-sq-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    margin-bottom: 8px;
    transition: all 0.2s;
}
.auto-sq-icon svg {
    width: 24px;
    height: 24px;
}

.auto-sq-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 2px;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.auto-sq-type {
    font-size: 10px;
    color: var(--text-tertiary);
}

.auto-sq-hint {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 8px;
    background: var(--card-color, var(--primary));
    color: white;
    font-size: 9px;
    font-weight: 600;
    opacity: 0.8;
}

.auto-sq-card .schedule-badge {
    margin-top: 4px;
    margin-bottom: 0;
    font-size: 9px;
    padding: 2px 6px;
}

@media (max-width: 768px) {
    .auto-sq-menu { opacity: 0.5; }
}

/* ===== History (Cronologia) ===== */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    transition: background var(--transition);
}
.history-item:hover {
    background: var(--bg-tertiary, var(--bg-secondary));
}
.history-item-icon {
    font-size: 20px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--bg);
    flex-shrink: 0;
}
.history-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.history-item-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-item-date {
    font-size: 12px;
    color: var(--text-secondary);
}
.history-item-error {
    font-size: 11px;
    color: #C0604A;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-item-status {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

/* Emoji & Color pickers for playlists */
.emoji-picker-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.emoji-pick {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    background: var(--bg);
    transition: all 0.15s;
}
.emoji-pick:active { transform: scale(0.92); }
.emoji-pick.selected {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.08);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}
.color-picker-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.color-pick {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
}
.color-pick:active { transform: scale(0.88); }
.color-pick.selected {
    border-color: var(--text);
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text);
}

/* ===== BUTTON EXAMPLES INLINE BUTTON ===== */
.btn-examples-inline {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-examples-inline:hover {
    border-color: var(--text-secondary);
    color: var(--text);
}
.btn-examples-inline:active {
    background: var(--bg-tertiary);
    transform: scale(0.95);
}

/* ===== BUTTON EXAMPLES MODAL ===== */
.btn-example-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: all 0.2s;
    cursor: pointer;
}
.btn-example-item:last-child {
    margin-bottom: 0;
}
.btn-example-item:active {
    transform: scale(0.98);
}
.btn-example-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
}
.btn-example-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-example-icon svg {
    width: 20px;
    height: 20px;
}
.btn-example-info {
    flex: 1;
    min-width: 0;
}
.btn-example-info h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}
.btn-example-info p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}
.btn-example-chevron {
    flex-shrink: 0;
    color: var(--text-tertiary);
    transition: transform 0.2s;
}
.btn-example-item.expanded .btn-example-chevron {
    transform: rotate(180deg);
}
.btn-example-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    padding: 0 14px;
}
.btn-example-item.expanded .btn-example-detail {
    max-height: 200px;
    padding: 0 14px 14px;
}
.btn-example-detail p {
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 8px;
}
.btn-example-input-tag {
    display: inline-block;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* ===== CALENDAR INVITE FORM ===== */

.calendar-invite-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.calendar-invite-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.calendar-invite-form label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.calendar-invite-form input,
.calendar-invite-form textarea {
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius, 8px);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.2s;
}

.calendar-invite-form input:focus,
.calendar-invite-form textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.calendar-invite-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 400px) {
    .calendar-invite-form .form-row {
        grid-template-columns: 1fr;
    }
}

/* ===== MAIL SECTION ===== */

#screen-mail .automation-container {
    overflow-y: hidden;
}

.mail-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.mail-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.mail-section-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.mail-layout {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
    min-height: 0;
}

.mail-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.mail-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-tertiary);
}

.mail-empty p {
    margin-top: 12px;
    font-size: 14px;
}

.mail-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.mail-item:hover {
    background: var(--bg-secondary);
    border-color: var(--border);
}

.mail-item:active {
    transform: scale(0.99);
}

.mail-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-light, rgba(79, 70, 229, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary);
}

.mail-item-content {
    flex: 1;
    min-width: 0;
}

.mail-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}

.mail-item-from {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-item-date {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
    flex-shrink: 0;
}

.mail-item-subject {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.mail-item-snippet {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

/* Mail Detail Panel */
.mail-detail-panel {
    display: none;
    flex-direction: column;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 16px;
}

.mail-detail-panel.open {
    display: flex;
}

.mail-detail-top-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.mail-detail-content {
    padding: 20px;
    overflow-y: auto;
    max-height: 60vh;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.mail-detail-placeholder {
    text-align: center;
    color: var(--text-tertiary);
    padding: 32px;
    font-size: 14px;
}

.mail-detail-header {
    margin-bottom: 16px;
}

.mail-detail-subject {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.mail-detail-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.mail-detail-from {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.mail-detail-date {
    font-size: 12px;
    color: var(--text-tertiary);
}

.mail-detail-body {
    font-size: 14px;
    color: var(--text);
    line-height: 1.7;
    padding: 16px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    word-break: break-word;
}

.mail-detail-actions {
    display: flex;
    gap: 8px;
    padding-top: 16px;
}

/* Mail Summary */
.mail-summary-box {
    margin-top: 16px;
    padding: 16px;
    background: var(--primary-light, rgba(79, 70, 229, 0.06));
    border: 1px solid var(--primary, #4F46E5);
    border-radius: 12px;
}

.mail-summary-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.mail-summary-text {
    font-size: 14px;
    color: var(--text);
    line-height: 1.6;
}

/* Mobile: mail detail becomes overlay */
@media (max-width: 768px) {
    .mail-detail-panel.open {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        margin: 0;
        border-radius: 0;
        border: none;
        touch-action: pan-y;
        overscroll-behavior: none;
    }

    .mail-detail-content {
        max-height: none;
        flex: 1;
        min-height: 0;
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }
}
