/* Dashboard specific styles - Modern Design */

.dashboard-container {
    width: 100%;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 2rem;
    box-sizing: border-box;
}

/* Modern Dashboard Header */
.dashboard-header {
    background: #1d3557;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.dashboard-header h2 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
}

/* Upload credit text */
.upload-credit {
    font-size: 1rem;
    font-weight: 500;
    border-radius: 6px;
    transition: width 0.3s ease-in-out;
}

/* Generic inline loading indicator */
.loading-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.loading-indicator .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e2e8f0;
    border-top-color: #1d3557;
    border-radius: 50%;
    animation: dashboard-spin 0.8s linear infinite;
}

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

/* Removed old subscription status block spacing */
.subscription-status-area {
    display: none;
}

/* === ENHANCED BUTTON STYLING === */

/* Base button styles for consistency */
.btn-primary, .btn-secondary, .btn-danger {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
    text-transform: none;
    letter-spacing: 0.02em;
    line-height: 1.2;
    min-height: 44px;
    box-sizing: border-box;
}

/* Shimmer effect for premium buttons */
.btn-primary::before,
.btn-secondary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s ease;
}

.btn-primary:hover::before,
.btn-secondary:hover::before {
    left: 100%;
}

/* Primary Button (Upload, Upgrade buttons) */
.btn-primary {
    background: #1d3557;
    color: white;
    box-shadow: 
        0 4px 15px rgba(29, 53, 87, 0.4),
        0 2px 6px rgba(0, 0, 0, 0.1);
    border: 2px solid transparent;
    background-clip: padding-box;
}

.btn-primary:hover:not(:disabled) {
    background: #152a45;
    transform: translateY(-3px);
    box-shadow: 
        0 8px 25px rgba(29, 53, 87, 0.5),
        0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 
        0 4px 15px rgba(29, 53, 87, 0.4),
        0 2px 6px rgba(0, 0, 0, 0.2);
}


/* Delete Button */
.btn-delete {
    background: #e2e8f0;
    color: #1a202c;
    border: none;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    min-width: 2.2rem;
}

.btn-delete::after {
    content: '🗑️';
    font-size: 1rem;
}

.btn-delete:hover:not(:disabled) {
    background: #d9d9d9;
}

.btn-delete:active:not(:disabled) {
    background: #cfd8e3;
}

/* Disabled state for all buttons */
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled,
.btn-delete:disabled,
.btn-disabled {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e0 100%) !important;
    color: #a0aec0 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    opacity: 0.6;
}

.btn-primary:disabled::before,
.btn-secondary:disabled::before,
.btn-danger:disabled::before,
.btn-delete:disabled::before {
    display: none;
}

/* Special styling for upgrade buttons in subscription area */
#subscription-actions .btn-primary {
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
    margin-left: 0.75rem;
    border-radius: 8px;
    min-width: 140px;
    background: #e63946; /* Accent red */
    color: #ffffff;
    border: 2px solid transparent;
    box-shadow: 0 4px 15px rgba(230, 57, 70, 0.4);
    transition: all 0.25s ease;
}

#subscription-actions .btn-primary:hover:not(:disabled) {
    background: #d62839; /* Darker on hover */
    box-shadow: 0 6px 20px rgba(230, 57, 70, 0.55);
    transform: translateY(-2px);
}

#subscription-actions .btn-secondary {
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
    margin-left: 0.75rem;
    border-radius: 8px;
    min-width: 140px;
}

/* Enhanced Add Script Button */
#addScriptBtn {
    padding: 1.2rem 2.5rem;
    font-size: 1.15rem;
    border-radius: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    z-index: 1;
    min-width: 200px;
}

/* Removed folder icon from upload button */

/* Loading state for buttons */
.btn-loading {
    pointer-events: none;
    position: relative;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: btn-spin 1s linear infinite;
}

@keyframes btn-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Button icons enhancement */
.btn-primary::before,
.btn-secondary::before,
.btn-danger::before {
    position: relative;
    z-index: 1;
}

/* Action buttons in table - specific enhancements */
.action-buttons .btn-secondary,
.action-buttons .btn-delete {
    padding: 0.7rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    min-width: 100px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-buttons .btn-delete::after {
    content: '🗑️';
    font-size: 1rem;
}

/* Focus states for accessibility */
.btn-primary:focus,
.btn-secondary:focus,
.btn-delete:focus {
    outline: none;
    box-shadow: 
        0 0 0 3px rgba(29, 53, 87, 0.3),
        0 4px 15px rgba(29, 53, 87, 0.4);
}

.btn-secondary:focus {
    box-shadow: 
        0 0 0 3px rgba(29, 53, 87, 0.3),
        0 4px 15px rgba(29, 53, 87, 0.4);
}

.btn-delete:focus {
    box-shadow:
        0 0 0 3px rgba(200, 200, 200, 0.7),
        0 4px 15px rgba(200, 200, 200, 0.5);
}

/* Special premium button variants */
.btn-premium {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 50%, #ffd700 100%);
    background-size: 200% 200%;
    color: #1a202c;
    font-weight: 700;
    box-shadow: 
        0 6px 20px rgba(255, 215, 0, 0.4),
        0 3px 8px rgba(0, 0, 0, 0.15);
}

.btn-premium:hover:not(:disabled) {
    background-position: right center;
    transform: translateY(-4px);
    box-shadow: 
        0 10px 30px rgba(255, 215, 0, 0.5),
        0 6px 15px rgba(0, 0, 0, 0.2);
}

/* Removed star icon from premium button */

/* Button group styling */
.button-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.button-group .btn-primary,
.button-group .btn-secondary,
.button-group .btn-danger {
    flex-shrink: 0;
}

/* === END ENHANCED BUTTON STYLING === */

/* Modern Scripts Table Container */
#scriptsList {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 25px rgba(0,0,0,0.08);
    overflow: hidden;
    border: 1px solid #f0f0f0;
}

/* Loading Indicator Styles */
.loading-indicator {
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background-color: #f8f9fa;
    border-radius: 12px;
    margin-bottom: 1rem;
    text-align: center;
}

.loading-indicator .spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #1d3557;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    animation: spin 1s linear infinite;
    margin-right: 1rem;
}

.loading-indicator span {
    font-size: 1.1rem;
    font-weight: 500;
    color: #4a5568;
}

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

/* Enhanced Table Styles */
.scripts-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.scripts-table thead {
    background: linear-gradient(135deg, #f8f9ff 0%, #e8f0fe 100%);
}

.scripts-table th {
    padding: 1.5rem 1.25rem;
    text-align: left;
    font-weight: 600;
    color: #4a5568;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
    position: relative;
}

.scripts-table th::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: #1d3557;
    opacity: 0.6;
}

.scripts-table td {
    padding: 1.25rem;
    border-bottom: 1px solid #f0f0f0;
    color: #2d3748;
    font-size: 0.95rem;
    vertical-align: middle;
}

/* Modern Row Styling */
.scripts-table tbody tr {
    transition: all 0.2s ease;
}

.scripts-table tbody tr:nth-child(even) {
    background-color: #f8f9ff;
}

.scripts-table tbody tr:hover {
    background-color: #e6f7ff;
    transform: scale(1.01);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.scripts-table tr.sample-script {
    background-color: #f0f4f8; /* A light blue-gray to distinguish sample rows */
}

.scripts-table tr.sample-script:hover {
    background-color: #e6eaf0;
}

.sample-tag {
    display: inline-block;
    margin-left: 10px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #1a5c3e;
    background-color: #c6f6d5;
    border-radius: 12px;
    vertical-align: middle;
    text-transform: uppercase;
}

/* Small label indicating current plan */
.plan-label {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #1d3557;
    background-color: #f1faee;
    border-radius: 10px;
}

/* Action Buttons Container */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center; /* Center the buttons horizontally */
}

/* Legacy action button styles - removed, now using enhanced styles above */

/* Upload Status Area Enhancement */
.upload-status-area {
    margin: 20px 0;
    padding: 15px;
    border-radius: 8px;
    background-color: #f0f4f8;
    display: none; /* Initially hidden */
}

.status-message {
    font-weight: 500;
    margin-bottom: 10px;
}

.status-message.error {
    color: #c53030; /* Red for errors */
    background-color: #fed7d7;
    padding: 10px;
    border-radius: 6px;
}

.status-message.success {
    color: #22543d; /* Dark green for success */
    background-color: #c6f6d5;
    padding: 10px;
    border-radius: 6px;
}

progress {
    width: 100%;
    height: 12px;
    border-radius: 6px;
    -webkit-appearance: none;
    appearance: none;
}

progress::-webkit-progress-bar {
    background-color: #e2e8f0;
    border-radius: 6px;
}

progress::-webkit-progress-value {
    background-color: #48bb78; /* Green progress */
    border-radius: 6px;
    transition: width 0.3s ease-in-out;
}

/* Style for subscription action buttons */
#subscription-actions .btn-secondary {
    padding: 9px 15px; /* Adjust padding to match upload button */
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 500;
}

/* No Scripts Message */
#noScriptsMessage {
    text-align: center;
    padding: 3rem 2rem;
    color: #718096;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 12px;
    margin: 2rem 0;
    border: 2px dashed #cbd5e0;
}

/* Removed document icon from no scripts message */

/* Responsive Design */
@media (max-width: 1024px) {
    .dashboard-container {
        padding: 1.5rem;
        margin: 1rem auto;
    }
    
    .dashboard-header {
        padding: 1.5rem;
    }
    
    .dashboard-header h1 {
        font-size: 2rem;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        padding: 1rem;
    }
    
    .dashboard-header {
        padding: 1.25rem;
        text-align: center;
    }
    
    .dashboard-header h1 {
        font-size: 1.75rem;
        margin-bottom: 1.5rem;
    }
    
    .subscription-status-area {
        text-align: center;
    }
    
    #addScriptBtn {
        width: 100%;
        justify-content: center;
        margin-top: 1rem;
    }
    
    /* Hide some table columns on mobile */
    .scripts-table th:nth-child(1),
    .scripts-table td:nth-child(1) {
        display: none;
    }
    
    .scripts-table th:nth-child(3),
    .scripts-table td:nth-child(3) {
        display: none;
    }
    
    .scripts-table th {
        padding: 1rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .scripts-table td {
        padding: 1rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .action-buttons .btn-secondary,
    .action-buttons .btn-delete {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    /* Use trash emoji on mobile for better UX */
    .action-buttons .btn-delete::after {
        content: '🗑️';
        font-size: 0.9rem;
        font-weight: normal;
    }
}

/* Smooth animations */
* {
    scroll-behavior: smooth;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Success/Error message styling */
.success-message {
    background: linear-gradient(135deg, #e8f5e9 0%, #f0fff4 100%);
    color: #22543d;
    border: 1px solid #c6f6d5;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    font-weight: 500;
}

.error-message {
    background: linear-gradient(135deg, #fed7d7 0%, #feb2b2 100%);
    color: #c53030;
    border: 1px solid #fc8181;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    font-weight: 500;
}

/* --- Upgrade Modal Styles --- */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.6);
    animation: fadeIn 0.5s;
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 30px;
    border: 1px solid #888;
    width: 80%;
    max-width: 700px;
    border-radius: 16px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: center;
    position: relative;
    animation: slideIn 0.5s;
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

/* --- PDF Preview Modal --- */
#previewModal .modal-content {
    width: 80%;
    max-width: 750px;
    height: 80vh;
    padding: 0;
    display: flex;
    flex-direction: column;
}
#previewModal .pdf-container {
    flex: 1;
    height: 100%;
}
#previewModal .pdf-container iframe {
    height: 100%;
}

.plan-options {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    gap: 20px;
    flex-wrap: wrap;
}

.plan-option {
    border: 2px solid #ddd;
    border-radius: 12px;
    padding: 20px;
    width: 30%;
    min-width: 250px;
    transition: all 0.3s ease;
    cursor: pointer;
    flex-grow: 1;
}

.plan-option:hover {
    border-color: #667eea;
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.2);
}

.plan-option h3 {
    margin-top: 0;
    color: #2d3748;
}

.plan-option .price {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
    margin: 10px 0;
}

@keyframes fadeIn {
    from {opacity: 0;}
    to {opacity: 1;}
}

@keyframes slideIn {
    from {transform: translateY(-50px); opacity: 0;}
    to {transform: translateY(0); opacity: 1;}
}

@media (max-width: 768px) {
    .plan-options {
        flex-direction: column;
    }
    .plan-option {
        width: 100%;
    }
}

.scripts-header-left {
    flex: 1;
    min-width: 200px;
}

.scripts-header-center {
    flex: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.scripts-header-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 15px; /* Add space between buttons */
    flex-direction: column; /* Stack button and hint */
    text-align: right;
}

.upload-hint {
    font-size: 0.8rem;
    color: #a0aec0;
    margin-top: -10px; /* Pull it closer to the button */
}

/* Ensure upload button sizes down on smaller widths */
@media (max-width: 768px) {
    #addScriptBtn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
        min-width: unset;
    }
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
    }
    .scripts-header-left, .scripts-header-center, .scripts-header-right {
        flex: unset;
        text-align: center;
    }
}

/* Prominent Upload Script button inside header */
.dashboard-header #addScriptBtn {
    background: #e63946; /* Accent red */
    color: #ffffff;
    border: 2px solid transparent;
    box-shadow: 0 4px 15px rgba(230, 57, 70, 0.4);
    transition: all 0.25s ease;
}

.dashboard-header #addScriptBtn:hover:not(:disabled) {
    background: #d62839; /* Darker on hover */
    box-shadow: 0 6px 20px rgba(230, 57, 70, 0.55);
    transform: translateY(-2px);
}

.dashboard-header #addScriptBtn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(230, 57, 70, 0.4);
}

/* ===== MOBILE OPTIMISATION ===== */
@media (max-width: 600px) {
    /* Update action buttons sizing */
    .action-buttons {
        justify-content: center;
    }
    .action-buttons .btn-secondary,
    .action-buttons .btn-delete {
        flex: 0 0 auto; /* shrink to content */
        min-width: 120px; /* uniform width */
        text-align: center;
    }

    /* Center the entire upload button section */
    .scripts-header-right {
        display: flex;
        justify-content: center;
    }

    /* Prevent full-width stretch & keep label centered */
    #addScriptBtn {
        width: auto;
        padding: 0.8rem 1.6rem;
        font-size: 1rem;
        text-align: center;
    }

    /* Turn the scripts table into card-style rows on small screens */
    .scripts-table, .scripts-table thead, .scripts-table tbody, .scripts-table th, .scripts-table td, .scripts-table tr {
        display: block;
        width: 100%;
    }

    .scripts-table thead {
        /* Hide header */
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .scripts-table tr {
        background: #fff;
        margin-bottom: 1rem;
        border-radius: 8px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.05);
        padding: 0.75rem 1rem;
    }

    .scripts-table td {
        /* Add label before each cell */
        text-align: left;
        padding: 0.5rem 0;
        position: relative;
    }

    .scripts-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280; /* gray-500 */
        display: block;
        margin-bottom: 0.25rem;
    }
}

/* iPhone SE / very narrow */
@media (max-width: 360px) {
    .dashboard-header h2 {
        font-size: 1.25rem;
    }
    #addScriptBtn {
        font-size: 0.85rem;
        padding: 0.6rem 1rem;
    }
} 

/* Explicitly center Rehearse text */
.action-buttons .btn-secondary{
    display:block;
    text-align:center;
    gap:0;
}

/* Align Preview, Rehearse and Delete buttons */
.action-buttons .preview-btn {
    flex-basis: 40%;
}

.action-buttons .rehearse-btn {
    flex-basis: 40%;
}

.action-buttons .trash-btn {
    flex-basis: 20%;
}

/* Row layout for action buttons */
.action-buttons{
    display:flex;
    gap:0.75rem;
    align-items:center;
    justify-content:center;
}
.action-buttons .preview-btn,
.action-buttons .rehearse-btn{
    flex:1 1 auto;
    min-width:140px;
}
.action-buttons .trash-btn{
    flex:0 0 64px;
    width:64px;
    height:64px;
    padding:0;
}

@media(max-width:768px){
    .action-buttons{
        flex-direction:row;
    }
    .action-buttons .preview-btn,
    .action-buttons .rehearse-btn{
        /* Ensure the buttons do not stretch full-width on small screens */
        width:auto !important;
        min-width:120px;
    }
    .action-buttons .preview-btn{
        display:none;
    }
    .action-buttons .trash-btn{
        width:56px;
        height:56px;
    }
}

/* Force horizontal layout regardless of earlier media queries */
.action-buttons{
    display:flex !important;
    flex-direction:row !important;
}

/* ----- FINAL LAYOUT OVERRIDE ----- */
.action-buttons {
    display: flex !important;
    flex-direction: row !important;
}

/* Harmonize trash button height with other action buttons */
.action-buttons .trash-btn {
    height: 44px !important; /* same as min-height of standard buttons */
    min-height: 44px !important;
    width: 56px; /* keep comfortable width */
}

/* Distinct styling for preview button */
.preview-btn {
    background: #6c757d;
    color: white;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.preview-btn:hover:not(:disabled) {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.4);
}