/**
 * RankStreak Student Tools Pro - Main Stylesheet
 * Version: 1.0.0
 * Mobile-First Responsive Design
 */

/* ==========================================================================
   CSS Variables - Design System
   ========================================================================== */
:root {
    --rst-primary: #2D5016;
    --rst-primary-hover: #1A3009;
    --rst-secondary: #4A90E2;
    --rst-accent: #F5A623;
    --rst-success: #28A745;
    --rst-warning: #FFC107;
    --rst-danger: #DC3545;
    --rst-bg-white: #FFFFFF;
    --rst-bg-light: #F8F9FA;
    --rst-input-bg: #F5F5F5;
    --rst-border: #E0E6ED;
    --rst-text-dark: #2C3E50;
    --rst-text-medium: #6C757D;
    --rst-text-light: #ADB5BD;
    --rst-radius-sm: 4px;
    --rst-radius-md: 8px;
    --rst-radius-lg: 12px;
    --rst-shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --rst-shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --rst-shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --rst-transition: all 0.3s ease;
}

/* ==========================================================================
   Base Calculator Container
   ========================================================================== */
.rst-calculator {
    max-width: 800px;
    margin: 0 auto 2rem;
    padding: 24px;
    background: var(--rst-bg-white);
    border-radius: var(--rst-radius-lg);
    box-shadow: var(--rst-shadow-md);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--rst-text-dark);
}

/* ==========================================================================
   Header Section
   ========================================================================== */
.rst-calc-header {
    text-align: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--rst-bg-light);
}

.rst-calc-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--rst-primary);
    margin: 0 0 8px 0;
}

.rst-calc-subtitle {
    font-size: 16px;
    color: var(--rst-text-medium);
    margin: 0;
    line-height: 1.5;
}

/* ==========================================================================
   Mode Selector (Tabs/Buttons)
   ========================================================================== */
.rst-calc-modes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
    padding: 12px;
    background: var(--rst-bg-light);
    border-radius: var(--rst-radius-md);
}

.rst-mode-btn {
    flex: 1 1 auto;
    min-width: 120px;
    padding: 12px 16px;
    background: var(--rst-bg-white);
    border: 2px solid var(--rst-border);
    border-radius: var(--rst-radius-md);
    font-size: 14px;
    font-weight: 600;
    color: var(--rst-text-dark);
    cursor: pointer;
    transition: var(--rst-transition);
    text-align: center;
}

.rst-mode-btn:hover {
    background: var(--rst-bg-light);
    border-color: var(--rst-primary);
    transform: translateY(-1px);
}

.rst-mode-btn.active {
    background: linear-gradient(135deg, var(--rst-primary) 0%, var(--rst-primary-hover) 100%);
    border-color: var(--rst-primary);
    color: var(--rst-bg-white);
    box-shadow: var(--rst-shadow-sm);
}

/* ==========================================================================
   Input Groups
   ========================================================================== */
.rst-calc-mode {
    margin-bottom: 24px;
}

.rst-input-group {
    margin-bottom: 16px;
    position: relative;
}

.rst-input-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--rst-text-dark);
    margin-bottom: 8px;
}

.rst-input,
.rst-select {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--rst-border);
    border-radius: var(--rst-radius-md);
    background: var(--rst-input-bg);
    color: var(--rst-text-dark);
    transition: var(--rst-transition);
    box-sizing: border-box;
    min-height: 44px; /* Touch-friendly */
}

.rst-input:focus,
.rst-select:focus {
    outline: none;
    border-color: var(--rst-primary);
    background: var(--rst-bg-white);
    box-shadow: 0 0 0 3px rgba(45, 80, 22, 0.1);
}

.rst-input.error {
    border-color: var(--rst-danger);
    background: #FFF5F5;
}

.rst-input-suffix {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    color: var(--rst-text-medium);
    pointer-events: none;
}

/* Number inputs - right align */
input[type="number"].rst-input {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Select dropdown styling */
.rst-select {
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%236C757D" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
    cursor: pointer;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.rst-btn-primary,
.rst-btn-secondary,
.rst-btn-icon,
.rst-btn-copy {
    border: none;
    cursor: pointer;
    transition: var(--rst-transition);
    font-family: inherit;
    font-weight: 600;
    text-align: center;
    display: inline-block;
    text-decoration: none;
}

.rst-btn-primary {
    background: linear-gradient(135deg, var(--rst-primary) 0%, var(--rst-primary-hover) 100%);
    color: var(--rst-bg-white);
    padding: 14px 28px;
    border-radius: var(--rst-radius-md);
    font-size: 16px;
    box-shadow: var(--rst-shadow-sm);
    min-height: 48px;
    min-width: 140px;
}

.rst-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(45, 80, 22, 0.3);
}

.rst-btn-primary:active {
    transform: translateY(0);
}

.rst-btn-secondary {
    background: var(--rst-bg-white);
    color: var(--rst-primary);
    border: 2px solid var(--rst-primary);
    padding: 12px 24px;
    border-radius: var(--rst-radius-md);
    font-size: 14px;
    min-height: 44px;
}

.rst-btn-secondary:hover {
    background: var(--rst-bg-light);
    transform: translateY(-1px);
}

.rst-btn-icon {
    background: var(--rst-bg-light);
    border: 1px solid var(--rst-border);
    padding: 8px 12px;
    border-radius: var(--rst-radius-sm);
    font-size: 18px;
    min-width: 40px;
    min-height: 40px;
}

.rst-btn-icon:hover {
    background: var(--rst-border);
}

.rst-btn-copy {
    background: var(--rst-secondary);
    color: var(--rst-bg-white);
    padding: 12px 24px;
    border-radius: var(--rst-radius-md);
    font-size: 15px;
    margin-top: 16px;
}

.rst-btn-copy:hover {
    background: #357ABD;
    transform: translateY(-1px);
}

.rst-btn-small {
    padding: 8px 16px;
    font-size: 13px;
    min-height: 36px;
}

/* Button groups */
.rst-calc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
    justify-content: center;
}

/* ==========================================================================
   Result Display
   ========================================================================== */
.rst-result-container {
    margin-top: 32px;
    animation: slideInUp 0.4s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rst-result-success {
    background: linear-gradient(135deg, var(--rst-success) 0%, #20833A 100%);
    color: var(--rst-bg-white);
    padding: 32px 24px;
    border-radius: var(--rst-radius-lg);
    text-align: center;
    box-shadow: 0 8px 24px rgba(40, 167, 69, 0.2);
}

.rst-result-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.rst-result-value {
    font-size: 42px;
    font-weight: 700;
    margin: 12px 0;
    line-height: 1.2;
}

.rst-result-label {
    font-size: 16px;
    opacity: 0.95;
    margin-top: 8px;
}

.rst-result-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 24px 0;
    padding: 20px;
    background: var(--rst-bg-light);
    border-radius: var(--rst-radius-md);
}

.rst-detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rst-detail-label {
    font-size: 13px;
    color: var(--rst-text-medium);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rst-detail-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--rst-text-dark);
}

.rst-result-formula {
    margin: 20px 0;
    padding: 16px;
    background: var(--rst-bg-light);
    border-left: 4px solid var(--rst-primary);
    border-radius: var(--rst-radius-sm);
    font-size: 14px;
}

.rst-result-formula strong {
    color: var(--rst-primary);
    margin-right: 8px;
}

.rst-result-steps {
    margin: 16px 0;
    padding: 16px;
    background: var(--rst-bg-white);
    border: 1px solid var(--rst-border);
    border-radius: var(--rst-radius-md);
    font-size: 14px;
    line-height: 1.8;
}

/* ==========================================================================
   Subject/Row Management
   ========================================================================== */
.rst-subject-row,
.rst-category-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 50px;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--rst-bg-light);
    border-radius: var(--rst-radius-md);
}

.rst-remove-subject,
.rst-remove-category {
    background: var(--rst-danger);
    color: var(--rst-bg-white);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: var(--rst-radius-sm);
    font-size: 20px;
    cursor: pointer;
    transition: var(--rst-transition);
}

.rst-remove-subject:hover,
.rst-remove-category:hover {
    background: #C82333;
    transform: scale(1.1);
}

/* ==========================================================================
   Semester/Category Sections
   ========================================================================== */
.rst-semester,
.rst-category-section {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--rst-bg-white);
    border: 2px solid var(--rst-border);
    border-radius: var(--rst-radius-lg);
}

.rst-semester h3,
.rst-category-section h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--rst-primary);
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--rst-bg-light);
}

/* ==========================================================================
   Radio & Checkbox Groups
   ========================================================================== */
.rst-radio-group,
.rst-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 12px 0;
}

.rst-radio-group label,
.rst-checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 15px;
}

.rst-radio-group input[type="radio"],
.rst-checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* ==========================================================================
   Textarea (Word Counter, Character Counter)
   ========================================================================== */
.rst-textarea {
    width: 100%;
    min-height: 300px;
    padding: 16px;
    font-size: 16px;
    font-family: inherit;
    border: 2px solid var(--rst-border);
    border-radius: var(--rst-radius-md);
    background: var(--rst-input-bg);
    color: var(--rst-text-dark);
    resize: vertical;
    transition: var(--rst-transition);
    box-sizing: border-box;
}

.rst-textarea:focus {
    outline: none;
    border-color: var(--rst-primary);
    background: var(--rst-bg-white);
    box-shadow: 0 0 0 3px rgba(45, 80, 22, 0.1);
}

/* ==========================================================================
   Stats Grid (Word Counter, Character Counter)
   ========================================================================== */
.rst-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.rst-stat-card {
    padding: 20px;
    background: linear-gradient(135deg, var(--rst-bg-light) 0%, #E8EDF2 100%);
    border-radius: var(--rst-radius-md);
    text-align: center;
    border: 1px solid var(--rst-border);
    transition: var(--rst-transition);
}

.rst-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--rst-shadow-sm);
}

.rst-stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--rst-primary);
    margin: 8px 0;
}

.rst-stat-label {
    font-size: 13px;
    color: var(--rst-text-medium);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   Progress Bars
   ========================================================================== */
.rst-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--rst-bg-light);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

.rst-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--rst-success) 0%, var(--rst-primary) 100%);
    transition: width 0.3s ease;
}

.rst-progress-fill.warning {
    background: linear-gradient(90deg, var(--rst-warning) 0%, var(--rst-accent) 100%);
}

.rst-progress-fill.danger {
    background: linear-gradient(90deg, var(--rst-danger) 0%, #C82333 100%);
}

/* ==========================================================================
   Timer Display (Pomodoro)
   ========================================================================== */
.rst-timer-display {
    text-align: center;
    margin: 32px 0;
}

.rst-timer-circle {
    width: 280px;
    height: 280px;
    margin: 0 auto 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rst-primary) 0%, var(--rst-primary-hover) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(45, 80, 22, 0.3);
    position: relative;
}

.rst-timer-time {
    font-size: 56px;
    font-weight: 700;
    color: var(--rst-bg-white);
    font-variant-numeric: tabular-nums;
}

.rst-timer-label {
    font-size: 16px;
    color: var(--rst-text-medium);
    margin-top: 12px;
}

.rst-timer-controls {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
}

/* ==========================================================================
   Calculator Display (Scientific Calculator)
   ========================================================================== */
.rst-calc-display {
    width: 100%;
    padding: 20px;
    font-size: 32px;
    font-weight: 700;
    text-align: right;
    background: var(--rst-text-dark);
    color: var(--rst-bg-white);
    border: none;
    border-radius: var(--rst-radius-md) var(--rst-radius-md) 0 0;
    font-variant-numeric: tabular-nums;
    min-height: 80px;
}

.rst-calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--rst-border);
    border-radius: 0 0 var(--rst-radius-md) var(--rst-radius-md);
    overflow: hidden;
}

.rst-calc-btn {
    padding: 20px;
    font-size: 18px;
    font-weight: 600;
    background: var(--rst-bg-light);
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    min-height: 60px;
}

.rst-calc-btn:hover {
    background: var(--rst-bg-white);
}

.rst-calc-btn:active {
    background: var(--rst-border);
}

.rst-calc-btn.operator {
    background: var(--rst-secondary);
    color: var(--rst-bg-white);
}

.rst-calc-btn.operator:hover {
    background: #357ABD;
}

.rst-calc-btn.equals {
    background: var(--rst-success);
    color: var(--rst-bg-white);
}

.rst-calc-btn.equals:hover {
    background: #20833A;
}

.rst-calc-btn.clear {
    background: var(--rst-danger);
    color: var(--rst-bg-white);
}

.rst-calc-btn.clear:hover {
    background: #C82333;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.rst-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    background: var(--rst-text-dark);
    color: var(--rst-bg-white);
    border-radius: var(--rst-radius-md);
    box-shadow: var(--rst-shadow-lg);
    font-size: 15px;
    font-weight: 600;
    z-index: 9999;
    animation: toastIn 0.3s ease-out;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rst-toast.success {
    background: var(--rst-success);
}

.rst-toast.error {
    background: var(--rst-danger);
}

/* ==========================================================================
   Loading State
   ========================================================================== */
.rst-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Responsive Design - Mobile First
   ========================================================================== */

/* Tablets (768px and below) */
@media screen and (max-width: 768px) {
    .rst-calculator {
        padding: 16px;
        margin: 0 auto 1.5rem;
    }
    
    .rst-calc-title {
        font-size: 24px;
    }
    
    .rst-calc-subtitle {
        font-size: 14px;
    }
    
    .rst-calc-modes {
        flex-direction: column;
    }
    
    .rst-mode-btn {
        min-width: 100%;
    }
    
    .rst-subject-row,
    .rst-category-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .rst-remove-subject,
    .rst-remove-category {
        width: 100%;
        height: 36px;
    }
    
    .rst-result-value {
        font-size: 32px;
    }
    
    .rst-calc-actions {
        flex-direction: column;
    }
    
    .rst-calc-actions button {
        width: 100%;
    }
    
    .rst-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .rst-stat-value {
        font-size: 24px;
    }
    
    .rst-timer-circle {
        width: 240px;
        height: 240px;
    }
    
    .rst-timer-time {
        font-size: 48px;
    }
    
    .rst-toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
}

/* Small Mobile (480px and below) */
@media screen and (max-width: 480px) {
    .rst-calc-title {
        font-size: 20px;
    }
    
    .rst-result-value {
        font-size: 28px;
    }
    
    .rst-detail-value {
        font-size: 20px;
    }
    
    .rst-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .rst-timer-circle {
        width: 200px;
        height: 200px;
    }
    
    .rst-timer-time {
        font-size: 40px;
    }
    
    .rst-calc-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .rst-calc-btn {
        padding: 16px;
        font-size: 16px;
        min-height: 50px;
    }
}

/* Print Styles */
@media print {
    .rst-calculator {
        box-shadow: none;
        border: 1px solid var(--rst-border);
    }
    
    .rst-calc-modes,
    .rst-calc-actions,
    .rst-btn-copy,
    .rst-remove-subject,
    .rst-remove-category {
        display: none;
    }
    
    .rst-result-container {
        page-break-inside: avoid;
    }
}

/* ==========================================================================
   Dark Mode (Optional - User Preference)
   ========================================================================== */
.rst-dark-mode {
    --rst-bg-white: #1A1A1A;
    --rst-bg-light: #2A2A2A;
    --rst-input-bg: #333333;
    --rst-border: #444444;
    --rst-text-dark: #E0E0E0;
    --rst-text-medium: #B0B0B0;
    --rst-text-light: #808080;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.rst-text-center {
    text-align: center;
}

.rst-mt-1 { margin-top: 8px; }
.rst-mt-2 { margin-top: 16px; }
.rst-mt-3 { margin-top: 24px; }
.rst-mb-1 { margin-bottom: 8px; }
.rst-mb-2 { margin-bottom: 16px; }
.rst-mb-3 { margin-bottom: 24px; }

.rst-hidden {
    display: none !important;
}

.rst-visible {
    display: block !important;
}