/**
 * Frontend Styles for Voting System Plugin
 * 
 * @package VotingSystem
 */

/* ==========================================================================
   Voting Interface Container
   ========================================================================== */

.vsp-voting-interface {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.vsp-voting-interface.vsp-voter-login {
    max-width: 500px;
}

/* ==========================================================================
   Header Styles
   ========================================================================== */

.vsp-voting-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #eee;
}

.vsp-org-logo {
    margin-bottom: 15px;
}

.vsp-org-logo img {
    max-height: 60px;
    width: auto;
}

.vsp-context-title {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 28px;
    font-weight: 600;
}

.vsp-org-title {
    margin: 0 0 15px 0;
    color: #666;
    font-size: 18px;
    font-weight: 400;
}

.vsp-context-description {
    color: #666;
    font-size: 16px;
    line-height: 1.5;
}

.vsp-voter-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 4px;
    margin-top: 15px;
    gap: 20px;
}

.vsp-welcome {
    font-weight: 600;
    color: #28a745;
}

.vsp-logout-link {
    color: #dc3545;
    text-decoration: none;
    font-size: 14px;
}

.vsp-logout-link:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Login Form Styles
   ========================================================================== */

.vsp-login-form-container {
    max-width: 400px;
    margin: 0 auto;
}

.vsp-login-form-container h3 {
    text-align: center;
    margin-bottom: 10px;
    color: #333;
}

.vsp-login-form-container p {
    text-align: center;
    margin-bottom: 25px;
    color: #666;
}

.vsp-form-field {
    margin-bottom: 20px;
}

.vsp-form-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.vsp-form-field input[type="text"],
.vsp-form-field input[type="email"],
.vsp-form-field input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.vsp-form-field input:focus {
    outline: none;
    border-color: #007cba;
}

.vsp-form-field input.vsp-field-error {
    border-color: #dc3545;
}

.vsp-form-actions {
    text-align: center;
    margin-top: 25px;
}

.vsp-submit-btn {
    background: #007cba;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    min-width: 120px;
}

.vsp-submit-btn:hover {
    background: #005a87;
}

.vsp-submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ==========================================================================
   Voting Content Styles
   ========================================================================== */

.vsp-voting-content {
    margin-top: 20px;
}

.vsp-no-ballots {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

/* ==========================================================================
   Ballot Styles
   ========================================================================== */

.vsp-ballot {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 25px;
    overflow: hidden;
}

.vsp-ballot:hover {
    border-color: #ddd;
}

.vsp-ballot.vsp-voted {
    background: #f8f9fa;
    border-color: #ddd;
}

.vsp-ballot-header {
    background: #fff;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.vsp-ballot-title {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 22px;
    font-weight: 600;
}

.vsp-ballot-description {
    color: #666;
    line-height: 1.5;
    margin: 0;
}

.vsp-ballot-meta {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    font-size: 14px;
    color: #666;
}

.vsp-ballot-type,
.vsp-ballot-status {
    padding: 4px 8px;
    border-radius: 3px;
    background: #e9ecef;
    font-weight: 500;
}

.vsp-ballot-status.open {
    background: #d4edda;
    color: #155724;
}

/* ==========================================================================
   Ballot Form Styles
   ========================================================================== */

.vsp-ballot-content {
    padding: 20px;
}

.vsp-ballot-form {
    margin-bottom: 20px;
}

.vsp-form-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.vsp-choice-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.vsp-choice-item {
    margin-bottom: 12px;
    padding: 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.vsp-choice-item:hover {
    background: #f8f9f9;
}

.vsp-choice-item label {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin: 0;
    font-weight: normal;
}

.vsp-choice-item input[type="radio"],
.vsp-choice-item input[type="checkbox"] {
    margin-right: 10px;
    transform: scale(1.2);
}

/* Write-in styles */
.vsp-write-in-container {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    display: none;
}

.vsp-write-in-container label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.vsp-write-in-container input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
}

/* Ranked choice styles */
.vsp-ranking-container {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
}

.vsp-ranking-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.vsp-ranking-number {
    font-weight: 600;
    min-width: 30px;
    color: #666;
}

.vsp-ranking-select {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Multiple choice constraints */
.vsp-choice-constraints {
    margin-bottom: 15px;
    padding: 10px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    font-size: 14px;
    color: #856404;
}

/* ==========================================================================
   Message Styles
   ========================================================================== */

.vsp-login-message,
.vsp-vote-message {
    margin: 15px 0;
    padding: 12px;
    border-radius: 4px;
    display: none;
}

.vsp-loading {
    background: #cce5ff;
    border: 1px solid #99d3ff;
    color: #004085;
}

.vsp-error {
    background: #f8d7da;
    border: 1px solid #f1aeb5;
    color: #721c24;
}

.vsp-success {
    background: #d4edda;
    border: 1px solid #a3d9a5;
    color: #155724;
}

.vsp-loading .spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #004085;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Voted Indicator
   ========================================================================== */

.vsp-voted-indicator {
    text-align: center;
    padding: 20px;
    color: #28a745;
    font-weight: 600;
    font-size: 18px;
}

.vsp-voted-indicator .dashicons {
    font-size: 24px;
    margin-right: 8px;
    vertical-align: middle;
}

/* ==========================================================================
   Form Actions
   ========================================================================== */

.vsp-ballot-actions {
    text-align: center;
    padding: 20px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

.vsp-vote-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    min-width: 120px;
}

.vsp-vote-btn:hover {
    background: #218838;
}

.vsp-vote-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

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

@media (max-width: 768px) {
    .vsp-voting-interface {
        margin: 10px;
        padding: 15px;
    }
    
    .vsp-context-title {
        font-size: 24px;
    }
    
    .vsp-ballot-title {
        font-size: 20px;
    }
    
    .vsp-voter-info {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .vsp-ballot-meta {
        flex-direction: column;
        gap: 8px;
    }
    
    .vsp-ranking-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .vsp-ranking-number {
        text-align: center;
    }
}

/* ==========================================================================
   Dashboard Icons (WordPress)
   ========================================================================== */

.dashicons {
    font-family: dashicons;
    display: inline-block;
    line-height: 1;
    font-weight: 400;
    font-style: normal;
    speak: none;
    text-decoration: inherit;
    text-transform: none;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 20px;
    vertical-align: top;
}

.dashicons-yes-alt:before { content: "\f147"; }
.dashicons-warning:before { content: "\f534"; }

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

.vsp-voting-interface :focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.vsp-choice-item input:focus + label {
    background: #e3f2fd;
}

/* Screen reader only content */
.vsp-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .vsp-voting-interface {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .vsp-logout-link,
    .vsp-submit-btn,
    .vsp-vote-btn {
        display: none;
    }
    
    .vsp-ballot {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .vsp-frontend-refresh-button {
        display: none;
    }
}

/* ==========================================================================
   Manual Refresh Button
   ========================================================================== */

.vsp-frontend-refresh-button {
    display: inline-flex;
    margin-left: 15px;
}

/* When inside voter info area */
.vsp-voter-info .vsp-frontend-refresh-button {
    margin-left: 15px;
    margin-top: 0;
}

/* Fallback positioning when not in voter info */
.vsp-voting-header > .vsp-frontend-refresh-button {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
}

.vsp-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #f8f9fa;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

.vsp-refresh-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #212529;
}

.vsp-refresh-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.vsp-refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f8f9fa;
}

.vsp-refresh-icon {
    font-size: 14px;
    line-height: 1;
    transition: transform 0.3s ease;
    display: inline-block;
}

.vsp-refresh-icon.vsp-refreshing {
    animation: vsp-spin 1s linear infinite;
}

@keyframes vsp-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.vsp-refresh-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    max-width: 400px;
    text-align: center;
}

.vsp-notification-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.vsp-notification-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.vsp-notification-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Mobile responsiveness for refresh button */
@media (max-width: 768px) {
    .vsp-voter-info {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .vsp-voter-info .vsp-frontend-refresh-button {
        margin-left: 0;
        justify-content: center;
    }
    
    .vsp-refresh-btn {
        font-size: 11px;
        padding: 5px 10px;
        gap: 3px;
    }
    
    .vsp-refresh-icon {
        font-size: 12px;
    }
    
    .vsp-refresh-notification {
        max-width: 300px;
        font-size: 13px;
        padding: 10px 16px;
    }
}