/* ===============================================
   ADVANCED SCREENSHOT & ANNOTATION TOOL STYLES
   =============================================== */

/* --- Main Tool Interface --- */
.tool-main {
    padding: var(--space-8) 0;
    min-height: calc(100vh - 152px);
}

/* --- Capture Section --- */
.capture-section {
    margin-bottom: var(--space-12);
}

.capture-card {
    background: var(--bg-primary);
    border-radius: var(--radius-2xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    text-align: center;
    max-width: 900px;
    margin: 0 auto;
}

[data-theme="dark"] .capture-card {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.capture-card h2 {
    font-size: 2.5rem;
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-4);
    color: var(--text-primary);
}

.capture-card > p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-8);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* --- Capture Modes --- */
.capture-modes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-6);
    margin-bottom: var(--space-8);
}

.capture-mode-btn {
    background: var(--bg-secondary);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

[data-theme="dark"] .capture-mode-btn {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.capture-mode-btn:hover {
    border-color: var(--brand-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.capture-mode-btn:active {
    transform: translateY(-1px);
}

.mode-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.capture-mode-btn h3 {
    font-size: 1.25rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: 0;
}

.capture-mode-btn p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

/* --- Privacy Notice --- */
.privacy-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(16, 185, 129, 0.1));
    border-radius: var(--radius-lg);
    color: var(--brand-primary);
    font-weight: var(--font-weight-medium);
    font-size: 0.9rem;
}

/* --- Loading Section --- */
.loading-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.loading-card {
    text-align: center;
    padding: var(--space-8);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--gray-200);
    border-top: 4px solid var(--brand-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--space-6) auto;
}

[data-theme="dark"] .loading-spinner {
    border-color: var(--gray-600);
    border-top-color: var(--brand-primary);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-card h3 {
    font-size: 1.5rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.loading-card p {
    color: var(--text-secondary);
}

/* --- Editor Section --- */
.editor-section {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

/* --- Editor Toolbar (Desktop/Tablet) --- */
.desktop-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    background: var(--bg-primary);
    border-bottom: 2px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

[data-theme="dark"] .desktop-toolbar {
    background: var(--bg-secondary);
    border-bottom-color: var(--border-color);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.export-group {
    gap: var(--space-3);
}

.toolbar-divider {
    width: 1px;
    height: 30px;
    background: var(--gray-300);
    margin: 0 var(--space-3);
}

[data-theme="dark"] .toolbar-divider {
    background: var(--border-color);
}

.tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 2px solid transparent;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-primary);
    font-size: 1.1rem;
}

[data-theme="dark"] .tool-btn {
    background: var(--bg-tertiary);
}

.tool-btn:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
}

[data-theme="dark"] .tool-btn:hover {
    background: var(--gray-700);
    border-color: var(--border-color);
}

.tool-btn.active {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
}

.tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-base);
    border: 2px solid var(--gray-300);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

[data-theme="dark"] .btn-secondary {
    border-color: var(--border-color);
    background: var(--bg-secondary);
}

.btn-secondary:hover {
    border-color: var(--brand-primary);
    background: var(--brand-primary);
    color: white;
}

/* --- Mobile Toolbar --- */
.mobile-toolbar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 2px solid var(--gray-200);
    padding: var(--space-3);
    z-index: 1001;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .mobile-toolbar {
    background: var(--bg-secondary);
    border-top-color: var(--border-color);
}

.mobile-toolbar-main {
    display: flex;
    align-items: center;
    justify-content: space-around;
    margin-bottom: var(--space-3);
}

.mobile-toolbar .tool-btn {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
}

.mobile-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 2px solid var(--gray-300);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-primary);
    font-size: 1.2rem;
}

[data-theme="dark"] .mobile-more-btn {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.mobile-export-group {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
}

.mobile-copy, .mobile-download {
    flex: 1;
    max-width: 150px;
    font-size: 0.9rem;
}

/* --- Tool Options Panel --- */
.tool-options {
    position: fixed;
    top: 100px;
    left: var(--space-6);
    background: var(--bg-primary);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    box-shadow: var(--shadow-lg);
    z-index: 1002;
    min-width: 250px;
}

[data-theme="dark"] .tool-options {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.option-group {
    margin-bottom: var(--space-4);
}

.option-group:last-child {
    margin-bottom: 0;
}

.option-group label {
    display: block;
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    font-size: 0.9rem;
}

.color-picker {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.color-picker input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
}

.color-presets {
    display: flex;
    gap: var(--space-2);
}

.color-preset {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition-base);
}

.color-preset:hover {
    transform: scale(1.1);
    border-color: var(--gray-400);
}

.color-preset.active {
    border-color: var(--text-primary);
    transform: scale(1.2);
}

input[type="range"] {
    width: 100%;
    margin: var(--space-2) 0;
}

.range-value {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
}

select {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-lg);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: var(--space-2);
}

[data-theme="dark"] select {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

/* --- Canvas Container --- */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .canvas-container {
    background: var(--gray-800);
}

#screenshotCanvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg);
    cursor: crosshair;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* --- Mobile Modals --- */
.mobile-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    max-height: 80vh;
    width: 100%;
    max-width: 500px;
    position: relative;
    z-index: 1;
    animation: slideUp 0.3s ease-out;
}

[data-theme="dark"] .modal-content {
    background: var(--bg-secondary);
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--gray-200);
}

[data-theme="dark"] .modal-header {
    border-bottom-color: var(--border-color);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-base);
}

[data-theme="dark"] .modal-close {
    background: var(--bg-tertiary);
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}

[data-theme="dark"] .modal-close:hover {
    background: var(--gray-600);
}

.modal-body {
    padding: var(--space-6);
    max-height: 60vh;
    overflow-y: auto;
}

.more-tools-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

.more-tools-grid .tool-btn {
    width: 100%;
    height: 80px;
    flex-direction: column;
    gap: var(--space-2);
    font-size: 1.5rem;
}

.more-tools-grid .tool-btn span {
    font-size: 0.8rem;
    font-weight: var(--font-weight-medium);
}

/* --- Text Input Modal Styles --- */
.text-input-modal {
    max-width: 400px;
    margin: auto;
}

.text-input-group {
    margin-bottom: var(--space-6);
}

.text-input-group label {
    display: block;
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    font-size: 0.9rem;
}

.text-input-group textarea {
    width: 100%;
    padding: var(--space-3);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-lg);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 1rem;
    resize: vertical;
    min-height: 80px;
    transition: border-color var(--transition-base);
}

[data-theme="dark"] .text-input-group textarea {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.text-input-group textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.text-input-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.option-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.option-row label {
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    font-size: 0.9rem;
    min-width: 60px;
}

.option-row input[type="color"] {
    width: 50px;
    height: 40px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-lg);
    cursor: pointer;
    background: none;
}

[data-theme="dark"] .option-row input[type="color"] {
    border-color: var(--border-color);
}

.option-row input[type="range"] {
    flex: 1;
    margin: 0 var(--space-2);
}

.text-size-value {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
    min-width: 40px;
}

.text-input-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

.text-input-actions .btn-secondary,
.text-input-actions .btn-primary {
    padding: var(--space-2) var(--space-4);
    font-size: 0.9rem;
    min-width: 80px;
}

/* --- Responsive Design --- */
@media (max-width: 1024px) {
    .tool-options {
        left: var(--space-4);
        min-width: 220px;
    }
    
    .desktop-toolbar {
        padding: var(--space-3) var(--space-4);
    }
    
    .toolbar-group {
        gap: var(--space-1);
    }
    
    .export-group {
        gap: var(--space-2);
    }
    
    .tool-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .btn-primary, .btn-secondary {
        padding: var(--space-2) var(--space-3);
        font-size: 0.85rem;
    }
}

@media (max-width: 640px) {
    .capture-modes {
        grid-template-columns: 1fr;
    }
    
    .capture-card {
        padding: var(--space-6);
        margin: 0 var(--space-4);
    }
    
    .capture-card h2 {
        font-size: 2rem;
    }
    
    .desktop-toolbar {
        display: none;
    }
    
    .mobile-toolbar {
        display: block;
    }
    
    .editor-section {
        padding-bottom: 140px; /* Account for mobile toolbar */
    }
    
    .tool-options {
        display: none !important; /* Use modal instead */
    }
    
    .canvas-container {
        padding: var(--space-4);
    }
    
    .text-input-modal {
        max-width: 90vw;
    }
    
    .text-input-actions {
        flex-direction: column;
    }
    
    .text-input-actions .btn-secondary,
    .text-input-actions .btn-primary {
        width: 100%;
    }
    
    .option-row {
        flex-wrap: wrap;
    }
    
    .option-row label {
        min-width: 100%;
        margin-bottom: var(--space-1);
    }
}

/* --- Utility Classes --- */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.cursor-crosshair {
    cursor: crosshair !important;
}

.cursor-grab {
    cursor: grab !important;
}

.cursor-grabbing {
    cursor: grabbing !important;
}

.cursor-text {
    cursor: text !important;
}

/* --- Canvas Drawing Styles --- */
.drawing-arrow {
    stroke: currentColor;
    stroke-width: 3;
    fill: none;
    marker-end: url(#arrowhead);
}

.drawing-rectangle {
    stroke: currentColor;
    stroke-width: 3;
    fill: none;
}

.drawing-circle {
    stroke: currentColor;
    stroke-width: 3;
    fill: none;
}

.drawing-text {
    font-family: var(--font-family);
    font-weight: var(--font-weight-medium);
    fill: currentColor;
}

.drawing-blur {
    filter: blur(10px);
}

.drawing-pixelate {
    filter: url(#pixelate);
    image-rendering: pixelated;
}

.step-number {
    fill: currentColor;
    stroke: white;
    stroke-width: 2;
    font-family: var(--font-family);
    font-weight: var(--font-weight-bold);
    text-anchor: middle;
    dominant-baseline: central;
}

/* --- Custom Scrollbar --- */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 3px;
}

[data-theme="dark"] .modal-body::-webkit-scrollbar-track {
    background: var(--gray-700);
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* --- Animation Classes --- */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* --- Success/Error States --- */
.success-message {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
    border: 1px solid var(--success);
    color: var(--success);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-weight: var(--font-weight-medium);
    text-align: center;
    margin: var(--space-4) 0;
}

.error-message {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
    border: 1px solid var(--error);
    color: var(--error);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-weight: var(--font-weight-medium);
    text-align: center;
    margin: var(--space-4) 0;
}

/* --- Focus States for Accessibility --- */
.tool-btn:focus,
.btn-primary:focus,
.btn-secondary:focus,
.capture-mode-btn:focus {
    outline: 3px solid var(--brand-primary);
    outline-offset: 2px;
}

.modal-close:focus {
    outline: 2px solid var(--brand-primary);
    outline-offset: 1px;
}

/* --- Print Styles --- */
@media print {
    .editor-section {
        position: static;
        background: white;
    }
    
    .desktop-toolbar,
    .mobile-toolbar,
    .tool-options,
    .mobile-modal {
        display: none !important;
    }
    
    .canvas-container {
        background: white;
        display: block;
        text-align: center;
    }
    
    #screenshotCanvas {
        max-width: 100%;
        height: auto;
    }
}
