/**
 * Restaurant Wheel Plugin Styles
 * 
 * Mobile-optimized CSS styles for the Restaurant Wheel WordPress plugin
 * Includes responsive design, accessibility features, and modern UI elements
 * 
 * @since 1.0.0
 * @package RestaurantWheel
 */

/* ==========================================================================
   MAIN CONTAINER STYLES
   ========================================================================== */

#restaurant-wheel-container {
	position: relative; /* Needed for absolute positioning inside */
    text-align: center;
    margin: 20px auto;
    max-width: 600px;
    padding: 0 15px; /* Add padding for mobile */
    box-sizing: border-box;
}

#wheel-pointer {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2em;
  color: red;
  z-index: 1000; /* Ensure it's above the canvas */
  pointer-events: none; /* So it doesn't interfere with clicks/taps */
}

/* ==========================================================================
   RESTAURANT SELECTION INTERFACE
   ========================================================================== */

#restaurant-selector {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Selection Controls (Select All/Deselect All) */
#selection-controls {
	margin-bottom: 20px;
    text-align: center;
}

#selection-controls .control-button {
    margin: 2px 5px;
    padding: 8px 16px;
    font-size: 0.9em;
    background-color: #95a5a6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    min-height: 40px;
    min-width: 100px;
    transition: background-color 0.2s, transform 0.1s;
    touch-action: manipulation;
}

#selection-controls .control-button:hover {
    background-color: #7f8c8d;
    transform: translateY(-1px);
}

#selection-controls .control-button:active {
    transform: translateY(0);
    background-color: #6c7b7d;
}

/* Desktop-specific styling for control buttons */
@media (min-width: 769px) {
    #selection-controls {
        display: flex !important;
        justify-content: center;
        align-items: center;
        gap: 10px;
    }
    
    #selection-controls .control-button {
        flex: 0 0 auto !important;
        width: auto !important;
        display: inline-block !important;
        margin: 5px !important;
        min-width: 120px;
    }
}

/* Restaurant Checkboxes */
#restaurant-checkboxes {
    text-align: left;
    margin-bottom: 20px;
}

/* Desktop 2-column layout */
@media (min-width: 769px) {
    #restaurant-checkboxes {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        align-items: start;
    }
}

#restaurant-checkboxes label {
    display: block !important;
    margin-bottom: 8px !important;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    min-height: 44px; /* Accessibility - minimum touch target */
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

/* Desktop-specific label styling */
@media (min-width: 769px) {
    #restaurant-checkboxes label {
        margin-bottom: 0 !important; /* Remove margin since we're using grid gap */
    }
}

#restaurant-checkboxes label:hover,
#restaurant-checkboxes label:focus-within {
    background-color: #f0f0f0;
}

#restaurant-checkboxes input[type="checkbox"] {
    margin-right: 8px !important;
    transform: scale(1.2); /* Larger checkboxes for mobile */
    cursor: pointer;
}

/* Action Buttons Container */
#action-buttons {
    text-align: center;
    margin-top: 20px;
}

/* ==========================================================================
   BUTTON STYLES
   ========================================================================== */

/* Primary Button Style (Create Wheel, Spin the Wheel) */
.primary-button,
#spin-button,
#save-selection {
    margin: 10px 5px;
    padding: 12px 20px;
    font-size: 1.1em;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    min-height: 44px; /* Accessibility - minimum touch target */
    min-width: 120px;
    transition: background-color 0.2s, transform 0.1s;
    touch-action: manipulation;
    font-weight: 600;
}

.primary-button:hover,
#spin-button:hover,
#save-selection:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
}

.primary-button:active,
#spin-button:active,
#save-selection:active {
    transform: translateY(0);
    background-color: #21618c;
}

/* Secondary Button Style (Reset) */
.secondary-button,
#reset-selection {
    margin: 10px 5px;
    padding: 12px 20px;
    font-size: 1.1em;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    min-height: 44px;
    min-width: 120px;
    transition: background-color 0.2s, transform 0.1s;
    touch-action: manipulation;
    font-weight: 600;
}

.secondary-button:hover,
#reset-selection:hover {
    background-color: #c0392b;
    transform: translateY(-1px);
}

.secondary-button:active,
#reset-selection:active {
    transform: translateY(0);
    background-color: #a93226;
}

/* ==========================================================================
   WHEEL CANVAS STYLES
   ========================================================================== */

#restaurant-wheel {
    max-width: 100%;
    height: auto;
    touch-action: manipulation; /* Optimize touch interactions */
}

/* ==========================================================================
   RESTAURANT INFO DISPLAY
   ========================================================================== */

#restaurant-info {
    margin-top: 20px;
    font-size: 1.1em;
    text-align: left;
}

#restaurant-info > div {
    background: #f9f9f9 !important;
    padding: 15px !important;
    border-radius: 5px !important;
    margin-top: 15px !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ==========================================================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ========================================================================== */

/* Tablet and smaller desktop */
@media (max-width: 768px) {
    #restaurant-wheel-container {
        margin: 10px auto;
        padding: 0 10px;
    }
    
    #restaurant-selector {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    /* Ensure single column on mobile/tablet */
    #restaurant-checkboxes {
        display: block !important;
        grid-template-columns: none !important;
        gap: 0 !important;
    }
    
    #restaurant-checkboxes label {
        margin-bottom: 8px !important;
    }
    
    /* Stack main action buttons vertically on mobile, but keep control buttons side by side */
    .primary-button,
    .secondary-button,
    #spin-button,
    #save-selection,
    #reset-selection {
        display: block;
        width: 100%;
        margin: 10px 0;
        font-size: 1.2em;
        padding: 15px;
    }
    
    /* Keep Select All/Deselect All buttons side by side on mobile */
    #selection-controls {
        display: flex !important;
        justify-content: center;
        gap: 2%;
    }
    
    #selection-controls .control-button {
        flex: 1;
        max-width: 48%;
        margin: 5px 0;
        font-size: 1.2em;
        padding: 15px;
        width: auto !important;
    }
    
    #restaurant-wheel {
        width: 100%;
        max-width: 300px; /* Smaller wheel on mobile */
    }
    
    #restaurant-info {
        font-size: 1em;
    }
    
    #restaurant-info > div {
        padding: 12px !important;
        margin-top: 10px !important;
    }
    
    #restaurant-info h3 {
        font-size: 1.3em;
        margin-bottom: 10px;
    }
    
    #restaurant-info p {
        margin-bottom: 8px;
        line-height: 1.4;
    }
    
    #restaurant-info a {
        word-break: break-all; /* Prevent long URLs from breaking layout */
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    #restaurant-wheel {
        max-width: 250px; /* Even smaller on very small screens */
    }
    
    #restaurant-checkboxes label {
        font-size: 1.1em;
        padding: 10px;
    }
    
    #restaurant-selector {
        padding: 10px;
    }
    
    /* Only on very small screens, stack the control buttons */
    #selection-controls {
        display: block !important;
    }
    
    #selection-controls .control-button {
        width: 100% !important;
        max-width: none !important;
        margin: 5px 0 !important;
        display: block !important;
    }
}

/* ==========================================================================
   LOADING AND ERROR STATES
   ========================================================================== */

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   ACCESSIBILITY FEATURES
   ========================================================================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    #restaurant-checkboxes label {
        border: 2px solid #000;
    }
    
    .primary-button,
    .secondary-button,
    .control-button {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .primary-button,
    .secondary-button,
    .control-button,
    #restaurant-checkboxes label {
        transition: none;
    }
    
    .loading-spinner {
        animation: none;
        border-top-color: #3498db;
    }
}

/* Focus styles for keyboard navigation */
#restaurant-checkboxes input[type="checkbox"]:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.primary-button:focus,
.secondary-button:focus,
.control-button:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.5);
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .primary-button,
    .secondary-button,
    .control-button,
    #restaurant-selector {
        display: none;
    }
    
    #restaurant-wheel {
        display: none;
    }
    
    #restaurant-info {
        break-inside: avoid;
    }
}