/**
 * Activity Log Pro Email Digest Settings Styles
 * 
 * Professional styling for email digest settings section with
 * responsive design and Activity Log Pro brand consistency.
 * 
 * @package    ActivityLogPro
 * @subpackage EmailDigest
 * @since      1.1.0
 * @author     Activity Log Pro Development Team
 */

/* ==========================================================================
   Email Digest Settings Section
   ========================================================================== */

/**
 * Main section styling with professional appearance.
 * 
 * Provides consistent spacing and visual hierarchy for the
 * email digest configuration section.
 */
.alp-settings-section h2 svg {
    color: #2271b1;
    vertical-align: middle;
    margin-right: 8px;
}

.alp-section-description {
    margin-top: 5px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #646970;
    line-height: 1.5;
}

/* ==========================================================================
   Email Digest Schedule Controls
   ========================================================================== */

/**
 * Schedule configuration layout and styling.
 * 
 * Creates intuitive day/time selection interface with
 * responsive behavior for mobile devices.
 */
.alp-email-digest-schedule {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.alp-email-digest-schedule span {
    font-weight: 500;
    color: #1d2327;
}

.alp-day-selector,
.alp-email-digest-schedule select {
    min-width: 120px;
    padding: 6px 10px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    background-color: #ffffff;
    font-size: 14px;
}

.alp-day-selector:focus,
.alp-email-digest-schedule select:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: none;
}

.alp-timezone-note {
    font-size: 12px;
    color: #646970;
    font-style: italic;
    margin-left: 5px;
}

/* ==========================================================================
   Email Recipients Textarea
   ========================================================================== */

/**
 * Recipients textarea with enhanced UX.
 * 
 * Provides clear visual feedback for email input with
 * proper sizing and validation styling.
 */
#actlogpro_email_digest_recipients {
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    line-height: 1.4;
    resize: vertical;
    min-height: 100px;
}

#actlogpro_email_digest_recipients:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

#actlogpro_email_digest_recipients::placeholder {
    color: #8c8f94;
    font-style: italic;
}

/* ==========================================================================
   Preview and Test Controls
   ========================================================================== */

/**
 * Action buttons with professional styling.
 * 
 * Provides consistent button appearance with loading states
 * and proper spacing for preview/test functionality.
 */
.alp-email-digest-preview {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.alp-preview-card {
    flex: 1;
    min-width: 300px;
    padding: 15px;
    background: #f6f7f7;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
}

.alp-preview-card h4 {
    margin: 0 0 10px 0;
    font-size: 13px;
    font-weight: 600;
    color: #1d2327;
}

.alp-preview-card p {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #50575e;
    flex-grow: 0;
}

.alp-email-input-group {
    margin-bottom: 10px;
}

.alp-email-input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 13px;
    color: #1d2327;
}

.alp-email-input-group input[type="email"] {
    width: 100%;
    max-width: 100%;
}

.alp-email-digest-preview .button {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.alp-email-digest-preview .button .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin-right: 5px;
    vertical-align: middle;
}

.alp-email-digest-preview .button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.alp-status-message-wrapper {
    margin-top: 12px;
}

.alp-preview-card .alp-status-message-wrapper {
    margin-top: 12px;
    margin-bottom: 0;
}

/* Preview URL Section Inside Card */
.alp-preview-url-section {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #dcdcde;
}

.alp-preview-url-label {
    font-weight: 600;
    font-size: 13px;
    color: #1d2327;
    margin: 0 0 8px 0;
}

.alp-preview-url-label .dashicons {
    vertical-align: middle;
    margin-right: 5px;
    color: #2271b1;
}

/* Preview Actions - Side by Side Buttons */
.alp-preview-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.alp-preview-actions .button {
    flex: 0 0 auto;
    min-width: auto;
}

.alp-preview-actions .button-link {
    font-size: 12px;
    padding: 4px 8px;
    text-decoration: none;
    color: #2271b1;
    display: inline-block;
}

.alp-preview-actions .button-link:hover {
    color: #135e96;
    text-decoration: underline;
}

.alp-preview-card .button {
    margin-top: auto;
    align-self: flex-start;
}

.alp-preview-url-code {
    display: block;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    font-family: Consolas, Monaco, monospace;
    font-size: 11px;
    color: #2271b1;
    word-break: break-all;
    margin-bottom: 8px;
    flex-grow: 0;
}

.alp-preview-url-action {
    margin: 0;
    margin-top: auto;
}

.alp-preview-url-action .button-link {
    text-decoration: none;
    font-size: 13px;
}

.alp-preview-url-action .button-link .dashicons {
    margin-right: 5px;
    vertical-align: middle;
    font-size: 16px;
}

/* ==========================================================================
   Status Messages
   ========================================================================== */

/**
 * Status message styling for user feedback.
 * 
 * Provides clear visual indication of success/error states
 * for email digest operations.
 */
.alp-status-message {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    margin-left: 10px;
    transition: all 0.3s ease;
}

.alp-status-success {
    background-color: #d1e7dd;
    color: #0a3622;
    border: 1px solid #a3cfbb;
}

.alp-status-error {
    background-color: #f8d7da;
    color: #58151c;
    border: 1px solid #f1aeb5;
}

/* ==========================================================================
   Modal Preview Window
   ========================================================================== */

/**
 * Modal dialog for email preview functionality.
 * 
 * Creates professional modal overlay with responsive behavior
 * and smooth animations for preview display.
 */
.alp-email-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100000;
    display: none;
    backdrop-filter: blur(3px);
}

.alp-email-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 900px;
    max-height: 90%;
    overflow: hidden;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.alp-email-modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #2271b1 0%, #3582c4 100%);
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.alp-email-modal-header h2 {
    margin: 0;
    color: white !important;
    font-size: 18px;
    font-weight: 600;
}

.alp-email-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.alp-email-modal-close:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
}

.alp-email-modal-body {
    padding: 0;
    position: relative;
}

#alp-preview-iframe {
    width: 100%;
    height: 600px;
    border: none;
    display: block;
}

/* ==========================================================================
   Conditional Visibility Animations
   ========================================================================== */

/**
 * Smooth transitions for conditional settings sections.
 * 
 * Provides polished show/hide animations when email digest
 * settings are enabled or disabled.
 */
.alp-email-digest-settings {
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.alp-email-digest-settings[style*="display: none"] {
    opacity: 0;
    visibility: hidden;
}

/* ==========================================================================
   Loading States and Animations
   ========================================================================== */

/**
 * Loading animations for async operations.
 * 
 * Provides visual feedback during preview loading and
 * test email sending operations.
 */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.button .dashicons.dashicons-update-alt {
    animation: spin 1s linear infinite;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/**
 * Mobile-responsive adjustments.
 * 
 * Ensures optimal user experience on smaller screens with
 * appropriate layout modifications and touch-friendly controls.
 */
@media screen and (max-width: 1200px) {
    .alp-preview-card {
        min-width: 280px;
    }
}

@media screen and (max-width: 782px) {
    .alp-email-digest-schedule {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .alp-day-selector,
    .alp-email-digest-schedule select {
        width: 100%;
        max-width: 250px;
    }
    
    .alp-email-digest-preview {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .alp-preview-card {
        min-width: 100%;
    }
    
    .alp-preview-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .alp-preview-actions .button {
        width: 100%;
        justify-content: center;
    }
    
    .alp-email-digest-preview .button {
        width: 100%;
        justify-content: center;
    }
    
    .alp-email-modal-content {
        width: 95%;
        max-height: 95%;
    }
    
    .alp-email-modal-header {
        padding: 15px 20px;
    }
    
    #alp-preview-iframe {
        height: 500px;
    }
    
    .alp-preview-card {
        min-width: 100%;
    }
    
    .alp-preview-url-code {
        font-size: 10px;
        padding: 6px 8px;
    }
}

@media screen and (max-width: 600px) {
    .alp-timezone-note {
        display: block;
        margin-top: 5px;
        margin-left: 0;
    }
    
    .alp-status-message {
        display: block;
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
        text-align: left;
    }
    
    .alp-preview-url-section {
        margin-top: 15px;
        padding-top: 12px;
    }
}

/* ==========================================================================
   Form Table Enhancements
   ========================================================================== */

/**
 * Enhanced form table styling for email digest section.
 * 
 * Provides better visual organization and spacing for
 * complex form controls within WordPress admin tables.
 */
.alp-settings-section .form-table th {
    position: relative;
}

.alp-settings-section .form-table td {
    position: relative;
}

.alp-settings-section .form-table .description {
    margin-top: 8px;
    margin-bottom: 0;
}

/* Description styling with emoji support */
.alp-settings-section .form-table .description:has-text("💡") {
    background-color: #fff9e6;
    border-left: 4px solid #dba617;
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 10px;
}

/* ==========================================================================
   Accessibility Enhancements
   ========================================================================== */

/**
 * Enhanced accessibility features.
 * 
 * Provides better focus indicators, screen reader support,
 * and keyboard navigation for all email digest controls.
 */
.alp-email-digest-schedule select:focus,
.alp-day-selector:focus,
#actlogpro_email_digest_recipients:focus {
    outline: 2px solid #2271b1;
    outline-offset: 1px;
}

.alp-email-modal-close:focus {
    outline: 2px solid #2271b1;
    outline-offset: 1px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .alp-status-success {
        background-color: #ffffff;
        color: #000000;
        border: 2px solid #008000;
    }
    
    .alp-status-error {
        background-color: #ffffff;
        color: #000000;
        border: 2px solid #dc3545;
    }
    
    .alp-email-modal-overlay {
        background: rgba(0, 0, 0, 0.9);
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .alp-email-digest-settings,
    .alp-email-modal-content,
    .alp-status-message,
    .button .dashicons.dashicons-update-alt {
        transition: none;
        animation: none;
    }
    
    .alp-email-modal-overlay {
        backdrop-filter: none;
    }
}

/* Email Template Styles (used in email HTML generation) */
.alp-email-logo {
    width: 64px;
    height: 64px;
    display: block;
    margin: 0 auto 15px auto;
    border-radius: 8px;
}

.alp-email-brand-name {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    color: white;
}

.alp-email-tagline {
    font-size: 16px;
    font-weight: 400;
    opacity: 0.9;
    color: white;
}

.alp-email-card {
    background: linear-gradient(135deg, #f0f6fc 0%, #e8f2ff 100%);
    border: 2px solid #2271b1;
    border-radius: 12px;
    padding: 24px;
    margin: 20px 0;
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.1);
    text-align: center;
}

.alp-email-card-title {
    font-size: 18px;
    color: #2271b1;
    margin-bottom: 12px;
    font-weight: 600;
}

.alp-email-stat-grid {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin: 15px 0;
}

.alp-email-stat-item {
    text-align: center;
    min-width: 120px;
}

.alp-email-stat-number {
    color: #2271b1;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 8px;
}

.alp-email-stat-label {
    font-size: 14px;
    color: #646970;
    font-weight: 500;
}

.alp-email-stat-divider {
    width: 2px;
    background: #2271b1;
    opacity: 0.3;
    margin: 0 10px;
    min-height: 50px;
}

/* ==========================================================================
   Email Digest Schedule Status Inline
   ========================================================================== */

/**
 * Schedule Status Inline Display
 * 
 * Subtle status information displayed inline within the form
 */
.alp-schedule-status-inline {
    margin-top: 15px;
    padding: 15px;
    background: #f7f7f7;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.alp-status-title {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #23282d;
}

.alp-status-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
}

.alp-status-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 0 15px;
    position: relative;
}

/* Vertical separators between columns */
.alp-status-separator::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #ddd;
}

.alp-status-label {
    font-size: 11px;
    font-weight: 600;
    color: #646970;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.alp-status-value {
    font-size: 13px;
    color: #1d2327;
    font-weight: 400;
}

.alp-status-active {
    color: #00a32a;
    font-weight: 600;
}

.alp-status-inactive {
    color: #d63638;
    font-weight: 600;
}

.alp-status-none {
    color: #8c8f94;
    font-style: italic;
}

/**
 * Responsive Design
 * Stack status items vertically on smaller screens
 */
@media (max-width: 1200px) {
    .alp-status-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px 0;
    }
    
    .alp-status-separator::before {
        display: none;
    }
    
    .alp-status-item:nth-child(odd)::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 1px;
        background: #ddd;
    }
}

@media (max-width: 782px) {
    .alp-status-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .alp-status-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid #eee;
    }
    
    .alp-status-item:last-child {
        border-bottom: none;
    }
    
    .alp-status-separator::before,
    .alp-status-item:nth-child(odd)::after {
        display: none;
    }
}
