/* ==========================================
   Blazored TextEditor / Quill - Dark Mode
   ========================================== */

/* Główny kontener Blazored */
.blazored-texteditor,
.ql-editor-container,
.quill-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
}

/* Wrapper dla całego komponentu */
[data-component="blazored-text-editor"],
.mud-paper > .quill-editor,
.mud-paper > div > .quill-editor {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
}

/* Toolbar - ciemne tło z jasnymi przyciskami */
.ql-toolbar.ql-snow {
    background: #1e1e1e;
    border: 1px solid #424242 !important;
    border-bottom: none !important;
    border-radius: 4px 4px 0 0;
    padding: 8px;
}

/* Przyciski toolbara - jasne/białe */
.ql-toolbar.ql-snow .ql-stroke {
    stroke: #e0e0e0 !important;
}

.ql-toolbar.ql-snow .ql-fill {
    fill: #e0e0e0 !important;
}

.ql-toolbar.ql-snow .ql-picker-label {
    color: #e0e0e0 !important;
}

.ql-toolbar.ql-snow .ql-picker-label::before {
    color: #e0e0e0 !important;
}

/* Strzałki dropdown */
.ql-toolbar.ql-snow .ql-picker-label svg {
    color: #e0e0e0 !important;
}

/* Hover na przyciskach - brand color (MudBlazor Primary) */
.ql-toolbar.ql-snow button:hover,
.ql-toolbar.ql-snow button:focus {
    background: #2d2d2d !important;
}

.ql-toolbar.ql-snow button:hover .ql-stroke,
.ql-toolbar.ql-snow button:focus .ql-stroke {
    stroke: #594ae2 !important;
}

.ql-toolbar.ql-snow button:hover .ql-fill,
.ql-toolbar.ql-snow button:focus .ql-fill {
    fill: #594ae2 !important;
}

.ql-toolbar.ql-snow .ql-picker-label:hover,
.ql-toolbar.ql-snow .ql-picker-label:hover::before {
    color: #594ae2 !important;
}

/* Aktywne przyciski */
.ql-toolbar.ql-snow button.ql-active {
    background: #2d2d2d !important;
}

.ql-toolbar.ql-snow button.ql-active .ql-stroke {
    stroke: #594ae2 !important;
}

.ql-toolbar.ql-snow button.ql-active .ql-fill {
    fill: #594ae2 !important;
}

.ql-toolbar.ql-snow .ql-picker-label.ql-active,
.ql-toolbar.ql-snow .ql-picker-label.ql-active::before {
    color: #594ae2 !important;
}

/* Edytor - ciemne tło */
.ql-container.ql-snow {
    background: #1e1e1e;
    border: 1px solid #424242 !important;
    border-radius: 0 0 4px 4px;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Placeholder - jasnoszary */
.ql-editor.ql-blank::before {
    color: #757575 !important;
    font-style: normal;
    opacity: 0.8;
}

.ql-editor:focus::before {
    color: #9e9e9e !important;
}

/* Treść edytora */
.ql-editor {
    color: #e0e0e0;
    padding: 12px 15px;
    line-height: 1.6;
    height: 100%;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.ql-editor:focus {
    outline: none;
    border-color: #594ae2;
}

/* Dropdown listy */
.ql-snow .ql-picker-options {
    background: #2d2d2d;
    border: 1px solid #424242;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.ql-snow .ql-picker-item {
    color: #e0e0e0;
}

.ql-snow .ql-picker-item:hover {
    background: #424242;
    color: #594ae2;
}

.ql-snow .ql-picker-item.ql-selected {
    color: #594ae2;
}

/* Tooltip */
.ql-snow .ql-tooltip {
    background: #2d2d2d;
    border: 1px solid #424242;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    color: #e0e0e0;
}

.ql-snow .ql-tooltip input[type=text] {
    background: #1e1e1e;
    border: 1px solid #424242;
    color: #e0e0e0;
}

.ql-snow .ql-tooltip a.ql-action::after,
.ql-snow .ql-tooltip a.ql-remove::after {
    color: #594ae2;
}

/* Separatory grup */
.ql-formats {
    margin-right: 8px !important;
}

/* Responsywność toolbara */
@media (max-width: 768px) {
    .ql-toolbar.ql-snow {
        padding: 6px;
    }
    
    .ql-formats {
        margin-right: 4px !important;
    }
    
    .ql-toolbar.ql-snow button {
        width: 28px !important;
        height: 28px !important;
    }
}

/* Lepsze wyświetlanie formatowanego tekstu w dark mode */
.ql-editor h2 {
    font-size: 1.5em;
    font-weight: 600;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    color: #e0e0e0;
}

.ql-editor h3 {
    font-size: 1.25em;
    font-weight: 600;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    color: #e0e0e0;
}

.ql-editor h4 {
    font-size: 1.1em;
    font-weight: 600;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    color: #e0e0e0;
}

.ql-editor ul, .ql-editor ol {
    padding-left: 1.5em;
}

.ql-editor blockquote {
    border-left: 4px solid #594ae2;
    padding-left: 16px;
    margin-left: 0;
    color: #bdbdbd;
    font-style: italic;
}

.ql-editor pre.ql-syntax {
    background: #2d2d2d;
    color: #e0e0e0;
    border-radius: 4px;
    padding: 12px;
    overflow-x: auto;
    border: 1px solid #424242;
}

.ql-editor a {
    color: #7986cb;
    text-decoration: underline;
}

.ql-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Wyrównanie obrazków przez data-align (Quill stosuje to bezpośrednio na <img>) */
.ql-editor img[data-align="center"],
.ql-editor img[style*="margin: auto"] {
    display: block !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

.ql-editor img[data-align="right"] {
    display: block !important;
    margin-left: auto !important;
    margin-right: 0 !important;
}

.ql-editor img[data-align="left"] {
    display: block !important;
    margin-left: 0 !important;
    margin-right: auto !important;
}

/* Zachowaj wyrównanie obrazków z Quill (dla paragrafów z klasą) */
.ql-editor .ql-align-center {
    text-align: center !important;
}

.ql-editor .ql-align-right {
    text-align: right !important;
}

.ql-editor .ql-align-left {
    text-align: left !important;
}

/* Wyrównanie dla obrazków w paragrafach */
.ql-editor p.ql-align-center,
.ql-editor p[style*="text-align: center"],
.ql-editor p[style*="text-align:center"] {
    text-align: center !important;
}

.ql-editor p.ql-align-center img,
.ql-editor p[style*="text-align: center"] img,
.ql-editor p[style*="text-align:center"] img {
    display: block !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

.ql-editor p.ql-align-right,
.ql-editor p[style*="text-align: right"],
.ql-editor p[style*="text-align:right"] {
    text-align: right !important;
}

.ql-editor p.ql-align-right img,
.ql-editor p[style*="text-align: right"] img,
.ql-editor p[style*="text-align:right"] img {
    display: block !important;
    margin-left: auto !important;
    margin-right: 0 !important;
}

.ql-editor p.ql-align-left,
.ql-editor p[style*="text-align: left"],
.ql-editor p[style*="text-align:left"] {
    text-align: left !important;
}

.ql-editor p.ql-align-left img,
.ql-editor p[style*="text-align: left"] img,
.ql-editor p[style*="text-align:left"] img {
    display: block !important;
    margin-left: 0 !important;
    margin-right: auto !important;
}

/* Selekcja tekstu */
.ql-editor ::selection {
    background: rgba(89, 74, 226, 0.3);
}

/* Przycisk disabled */
.ql-toolbar.ql-snow button:disabled {
    opacity: 0.3;
}

.ql-toolbar.ql-snow button:disabled .ql-stroke {
    stroke: #757575 !important;
}

.ql-toolbar.ql-snow button:disabled .ql-fill {
    fill: #757575 !important;
}

/* Separatory grup */
.ql-formats {
    margin-right: 8px !important;
}

/* Responsywność toolbara */
@media (max-width: 768px) {
    .ql-toolbar.ql-snow {
        padding: 6px;
    }
    
    .ql-formats {
        margin-right: 4px !important;
    }
    
    .ql-toolbar.ql-snow button {
        width: 28px !important;
        height: 28px !important;
    }
}

/* Lepsze wyświetlanie formatowanego tekstu */
.ql-editor h2 {
    font-size: 1.5em;
    font-weight: 600;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

.ql-editor h3 {
    font-size: 1.25em;
    font-weight: 600;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

.ql-editor ul, .ql-editor ol {
    padding-left: 1.5em;
}

.ql-editor blockquote {
    border-left: 4px solid #1976d2;
    padding-left: 16px;
    margin-left: 0;
    color: #616161;
    font-style: italic;
}

.ql-editor pre.ql-syntax {
    background: #f5f5f5;
    color: #212121;
    border-radius: 4px;
    padding: 12px;
    overflow-x: auto;
}

.ql-editor a {
    color: #1976d2;
    text-decoration: underline;
}

.ql-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    display: inline-block;
}

/* Zachowaj wyrównanie obrazków (Light Mode) */
.ql-editor .ql-align-center {
    text-align: center;
}

.ql-editor .ql-align-right {
    text-align: right;
}

.ql-editor .ql-align-left {
    text-align: left;
}

.ql-editor p.ql-align-center img,
.ql-editor p[style*="text-align: center"] img {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.ql-editor p.ql-align-right img,
.ql-editor p[style*="text-align: right"] img {
    display: block;
    margin-left: auto;
    margin-right: 0;
}

.ql-editor p.ql-align-left img,
.ql-editor p[style*="text-align: left"] img {
    display: block;
    margin-left: 0;
    margin-right: auto;
}
